Wednesday, June 16, 2010

Screen Scraping

Screen Scraping (web response) with web request object


 

If you need to intercept the response stream from any url which in other words said as Screen Scraping. In the below example I have created a uri object to create a Webrequest.Create(strUrl).

Uri url = new
Uri("http://www.google.com");

WebRequest wr = WebRequest.Create(url);

WebResponse response = wr.GetResponse();

StreamReader sr = new
StreamReader (response.GetResponseStream ());

string result = sr.ReadToEnd();

Response.Write(result);


 

Note: Before accessing the url try with TelNet and check whether the url is sending any response.


 

……. HaPpY CoDinG

Partha (Aurum)

No comments:

Post a Comment