0

Is there any way in C# to open a browser using a link and save the loaded html page ?? Actually i don't want to inform server that i am using any software or script .

Actually I want data from this link : http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&rt=nc&item=120840650200&si=a8iGAIchyvEbn7KveYFZ5QbEE7o%3D&print=all&category=10363 if I try to download the page using webclient it send me another page not the original one. when i load the previous url in a browser it is redirected to this link: http://www.ebay.com/itm/ws/eBayISAPI.dll?ViewItem&rt=nc&item=120840650200&si=a8iGAIchyvEbn7KveYFZ5QbEE7o%3D&print=all&category=10363 which is the original page I want to download

so I just wanted to open the browser using the url and save the loaded page. Thanks in advance

2 Answers 2

2

Do you really need to open the browser, or is just (inconspicuously) retrieving the file enough? If so, you can use System.Net.Webclient or System.Net.HttpWebRequest/HttpWebResponse. The former option is much easier, but the latter will allow you to set your own user-agent string to one that would match that of common web browsers.

Sign up to request clarification or add additional context in comments.

1 Comment

You could just use the Headers property on WebClient and add the user-agent that way rather than defer to HttpWebRequest.
2

Straight from MSDN

WebClient client = new WebClient();
Byte[] pageData = client.DownloadData("http://www.contoso.com");
string pageHtml = Encoding.ASCII.GetString(pageData);
Console.WriteLine(pageHtml);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.