Reputation: 1423
I'd like to capture the HTML code off a page and place it into a text file. Unfortunatel I get an error of the following:
"The remote server returned an error: (407) Proxy Authentication Required."
Anyone know how to solve this?
string url = @"http://www.panalpina.com/www/global/en/tools_resources/unit_converter/currency_codes.html";
HttpWebRequest myWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
myWebRequest.Method = "GET";
// make request for web page
myWebRequest.ToString();
HttpWebResponse myWebResponse = (HttpWebResponse)myWebRequest.GetResponse();
StreamReader myWebSource = new StreamReader(myWebResponse.GetResponseStream());
string myPageSource = string.Empty;
myPageSource = myWebSource.ReadToEnd();
myWebResponse.Close();
`
Upvotes: 1
Views: 1247
Reputation: 5103
It seems you are using proxy server to connect to internet. If yes add next code before http request send:
myWebRequest.Proxy = new WebProxy("you_proxy_machine", 8080 /*port*/);
myWebRequest.Proxy.Credentials = new NetworkCredential("proxy_username", proxy_password");
Upvotes: 1