I'm using the code below to pull one of our 3rd party developed pages in so I can parse it as XML for my random bits of work.
Irritatingly we stil have a browser detection level set on the server that only allows certain browsers on to the site; so the question is how would I fake it so that the server thinks its a browser request?
static string GetHtmlPage(string strURL)
{
String strResult;
System.Net.WebResponse objResponse;
System.Net.WebRequest objRequest = System.Net.HttpWebRequest.Create(strURL);
objResponse = objRequest.GetResponse();
using (System.IO.StreamReader sr = new System.IO.StreamReader(objResponse.GetResponseStream()))
{
strResult = sr.ReadToEnd();
sr.Close();
}
return strResult;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…