|
Hello community,
In advance, please excuse my lack of knowledge regarding the following topic, I have tried to familiarise myself with the topic using both google and the search function.
A friend of mine asked whether I could get data from a specific website for him, I answered "yes, I can try". I feel like I am pretty close and only need a final push. So let's go:
www.regelleistung.net -> this is the website in question
Menu item : Data for Control Reserve - in the following form he would normally specify what kind of data he is interested in and would then click the submit button .
Someone gave me the TAMPER information for the post request and I came up with the following code:
1. The request requires a jsession cookie which I retrieve + from TAMPER I saw that I require several other items of interest : __fp , _sourcePage and CSRFToken.
Because I do not know how to get those information without making an actual request - I just perform a testrequest and populate an array, which I will use for the actual request
BASEURL = @"https://www.regelleistung.net/ip/action/abrufwert";
public string[] ReceiveCookiesAndHiddenData()
{
string[] tempHidden = new string[4];
HttpWebRequest tempRequest = (HttpWebRequest)WebRequest.Create(BASEURL);
using (HttpWebResponse tempResponse = (HttpWebResponse)tempRequest.GetResponse())
{
HtmlDocument doc = new HtmlDocument();
doc.Load(tempResponse.GetResponseStream());
tempHidden[0] = doc.DocumentNode.SelectNodes("//input[@type='hidden' and @name='_sourcePage']")[0].Attributes["Value"].Value;
tempHidden[1] = doc.DocumentNode.SelectNodes("//input[@type='hidden' and @name='__fp']")[0].Attributes["Value"].Value;
tempHidden[2] = doc.DocumentNode.SelectNodes("//input[@type='hidden' and @name='CSRFToken']")[0].Attributes["Value"].Value;
tempHidden[3] = tempResponse.Headers["Set-Cookie"].Split(new Char[] { ';' })[0];
}
return tempHidden;
}
2. No I have to make the actual request. which requires the following information (according to Tamper):
http://pl.vc/3f5z0[^]
public void MakeActualRequest()
{
hiddenData = ReceiveCookiesAndHiddenData();
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(BASEURL);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
request.Referer = "https://www.regelleistung.net/ip/action/abrufwert";
request.Headers.Add("Set-Cookie",hiddenData[3]);
NameValueCollection outgoingQueryString = HttpUtility.ParseQueryString(String.Empty);
outgoingQueryString.Add("von", "05.08.2014");
outgoingQueryString.Add("uenbld", "STXs440zwks=");
outgoingQueryString.Add("produkt", "MRL");
outgoingQueryString.Add("work", "anzeigen");
outgoingQueryString.Add("_sourcePage", hiddenData[0]);
outgoingQueryString.Add("__fp", hiddenData[1]);
outgoingQueryString.Add("CSRFToken", hiddenData[2]);
string postdata = outgoingQueryString.ToString();
byte[] data = Encoding.ASCII.GetBytes(postdata);
request.ContentLength = data.Length;
using(Stream requestStream = request.GetRequestStream())
{
requestStream.Write(data,0,data.Length);
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
using(StreamReader reader = new StreamReader(responseStream, Encoding.Default))
{
string content = reader.ReadToEnd();
}
}
I receive a WeException "Remote server error :(403)" in this line of code:
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
I would be thankfull for help. I know this is like the 1000000 time such a question has been posted, but I read all those threads and still cannot figure it out.
Thank you all!
|
|
|
|
|
Look at the action parameter of the form element
form action="/ip/action/abrufwert;jsessionid=v8fcThPBr1LQcMds3PrkXxwJNwYpzvQ6Zb9vcNyTMQhk9d96Bhb8!2134477355!-1323386705" method="post"
There's the URL you have to send the data to in MakeActualRequest , not BASEURL .
Also parameters "bis" and "download" are missing in your request.
|
|
|
|
|
Hi Bernhard,
thanks - Adding the jsessionid to the uri already helped solving my first issue - then changing uenbld to uenbId did the final trick.
Thanks for the quick and helpful response, highly appreciated.
Question answered!
|
|
|
|
|
i do not the main objective of using bar code but guessed that people store & hide info through bar code for to some extent security. may be i am not correct.....if anyone knows the exact objective for storing info in bar code then plzz share with me. thanks
tbhattacharjee
|
|
|
|
|
All a bar code contains is an Article Number (AN) - which is a unique identifier for a product type. So a 100g chocolate bar will have one AN, and a 100g chocolate bar from a different manufacturer will have a different one. a 200g bar from the same manufacturer will also have a different AN.
What that means is that you can scan teh product barcode, and get a number which lets you go to your database, look up the AN and get told "this is a Cadburys Dairy Milk 100g and we are selling it at £1.50, we have 72 in stock and we reorder if the stick level drops to 71". Without the user or operator having to enter any information (with the good probability that he will make a mistake).
It's not security, it's just a number (which contains a simple checksum code) which identifies something. Everything else is a database / application function.
(There are barcode types which contain more information than this - a lot more in some cases - but that's the general idea)
You looking for sympathy?
You'll find it in the dictionary, between sympathomimetic and sympatric
(Page 1788, if it helps)
|
|
|
|
|
thanks a lot for good explanation
tbhattacharjee
|
|
|
|
|
You're welcome!
You looking for sympathy?
You'll find it in the dictionary, between sympathomimetic and sympatric
(Page 1788, if it helps)
|
|
|
|
|
Hi,
Is it possible to generate vcf contact file using C# and .NET 4.0? or need to use thirdparty only?
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
Yes, it's possible. Assuming you are a reasonably competent C# programmer, and know how to use Google to find the documents that define the vCard format.
|
|
|
|
|
See this[^] example.
/ravi
|
|
|
|
|
I managed to generate the vcf file using the below code from your reply and I am able to open it on my PC and m Samsung Galaxy S5 but not the iPhone. Why is that?
var contact = new GoogleContacts()
{title = "Mr.", first_name = "Kookoo", last_name = "NooNoo", work_phone = "17171717", mobile_phone = "39393939", email = "jassim@myemail.com", im = "jasmanskype" };
var vcf = new StringBuilder();
vcf.Append("BEGIN:VCARD" + System.Environment.NewLine);
vcf.Append("VERSION:3.0" + System.Environment.NewLine);
vcf.Append("TEL;type=HOME;type=VOICE;type=pref:" + contact.mobile_phone + System.Environment.NewLine);
vcf.Append("FN:" + contact.first_name + " " + contact.last_name + System.Environment.NewLine);
vcf.Append("END:VCARD" + System.Environment.NewLine);
var filename = @"C:\temp\mycontact.vcf";
System.IO.File.WriteAllText(filename, vcf.ToString());
Technology News @ www.JassimRahma.com
|
|
|
|
|
I suspect your iOS code is buggy.
/ravi
|
|
|
|
|
but I tried it with more than one iphone..
Technology News @ www.JassimRahma.com
|
|
|
|
|
Are you saying you ran the same code on more than one iPhone?
/ravi
|
|
|
|
|
Uhhh, if your code is buggy, how is changing out the phone going to fix that??
You might want to try and find out if the iPhone can successfully read and process a vCard file and/or what it's looking for in the vCard.
|
|
|
|
|
so you mean the coded I posted is correct and exported vcf should work on iPhone? do I need to add any special element in the file to make it compatible with iPhone?
Technology News @ www.JassimRahma.com
|
|
|
|
|
Jassim Rahma wrote: so you mean the coded I posted is correct and exported vcf should work on iPhone
Where on earth did I say that?
Jassim Rahma wrote: do I need to add any special element in the file to make it compatible with
iPhone?
That's a researtch project for you. I have no idea and I've got my own research to do on my own problems.
|
|
|
|
|
Hi, I am opening the UDL file from Browse button in WPF application. After clicking on OK button of UDL wizard connection information should be displayed in WPF application's Datagrid. Please give me any way to do this.
|
|
|
|
|
You have already posted this question in the .NET Framework forum[^].
Posting the same question in multiple forums on the same site is only going to annoy the people who would otherwise be trying to help you.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
// datagridview name is dgdaily.
i got error
"System.NullReferenceException occurred
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=final
StackTrace:
at final.DailySheet.UpdateLabelText() in h:\final\final\final\DailySheet.cs:line 122
InnerException:
"
//my code start
updatelabeltext()
{
Label[] la= new Label[10];
int counter1;
int counter2;
int i = 0;
for (counter1 = 0; counter1 < (dgdaily.Rows.Count-1); counter1++)
{
int sum = 0;
if (dgdaily.Rows[counter1].Cells["destination"].Value != null)
{
string x = dgdaily.Rows[counter1].Cells["destination"].Value.ToString();
int descount = 1;
for (counter2 = 1; counter2 < (dgdaily.Rows.Count-1); counter2++)
{
string y = dgdaily.Rows[counter2].Cells["destination"].Value.ToString();
if (x==y)
{
descount++;
sum = descount - 1;
}
}
la[i].Text = dgdaily.Rows[counter1].Cells["destination"].Value.ToString()+":" + sum.ToString();
i++;
}
}
}
|
|
|
|
|
Member 10991491 wrote: StackTrace:
at final.DailySheet.UpdateLabelText() in h:\final\final\final\DailySheet.cs:line 122 Which line of your code snippet is line 122?
Member 10991491 wrote: InnerException: What's the inner exception?
|
|
|
|
|
Hi,
I need a code for printing a receipt in a WPF (C#) application using PrintDocument or another one else.
Thanks
|
|
|
|
|
OK. The only code you're going to get is the code that YOU write yourself.
Nobody here is going to do it for you and just Googling around for "print a receipt from a WPF app" is going to get you some vague code samples that you're going to have to adapt anyway.
|
|
|
|
|
your code is totaly right but still some thig error is held in this code so please check it oncve again please
|
|
|
|
|
Uhhh...Just who do you think you're replying to?
|
|
|
|