No recent searches
Popular Articles
Sorry! nothing found for
Posted almost 4 years ago by gac
I tried following but it fails with 407.
var myProxy = new WebProxy("http://proxy.crawlera.com:8010", true);
myProxy.Credentials = new NetworkCredential("xxx", "");
var request = (HttpWebRequest)WebRequest.Create("https://httpbin.scrapinghub.com/headers");
request.Proxy = myProxy;
request.PreAuthenticate = true;
request.AllowAutoRedirect = false;
request.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
var response = request.GetResponse();
Console.WriteLine("Response Status: " + ((HttpWebResponse)response).StatusDescription);
Console.WriteLine("\nResponse Headers:\n" + ((HttpWebResponse)response).Headers);
var dataStream = response.GetResponseStream();
var reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
Console.WriteLine("Response Body:\n" + responseFromServer);
reader.Close();
response.Close();
0 Votes
0 Comments
Login to post a comment
People who like this
This post will be deleted permanently. Are you sure?
I tried following but it fails with 407.
var myProxy = new WebProxy("http://proxy.crawlera.com:8010", true);
myProxy.Credentials = new NetworkCredential("xxx", "");
var request = (HttpWebRequest)WebRequest.Create("https://httpbin.scrapinghub.com/headers");
request.Proxy = myProxy;
request.PreAuthenticate = true;
request.AllowAutoRedirect = false;
request.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
var response = request.GetResponse();
Console.WriteLine("Response Status: " + ((HttpWebResponse)response).StatusDescription);
Console.WriteLine("\nResponse Headers:\n" + ((HttpWebResponse)response).Headers);
var dataStream = response.GetResponseStream();
var reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
Console.WriteLine("Response Body:\n" + responseFromServer);
reader.Close();
response.Close();
0 Votes
0 Comments
Login to post a comment