Sunday, July 17, 2011

Screen Scraping

Screen Scrapping is how we can use server side code issuing an HTTP request to some other Web site, retrieving the returned results, and processing these results in some manner.
Use System.IO and System.Net to accomplish this task.

string url = string.Empty;
WebProxy prxy = new WebProxy("http://1.0.0.0");
url = "http://www.abc.com";

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);

req.Method = "GET";
req.Proxy = prxy;

try
{
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
}
catch (System.Net.WebException ex)
{
TextBox1.Text = ex.Status.ToString();
}

No comments: