Purpose
Screen Scraping is used to extract data from a web page by scraping it instead of more direct access. It involves requesting the page and then parsing the response. It is useful in situations where direct access to the data is not there.
Implementation
Suppose we want to scrape Email addresses from live web sites. It would be a two-step process with first fetching the page and then parsing the response contents to extract the email addresses.
We have created a class called Extract (shown below) which has an API called GetPage() which fetches the page given a URL.

System.Net namespace contain classes which can be used to fetch the page. The classes we are going to use are HttpWebRequest and HttpWebResponse.
Below is the GetPage() API :
public string GetPage()
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(this.URL.Trim());
request.ContentType = "text/html";
request.Method = "GET";
request.Proxy = WebProxy.GetDefaultProxy();
request.Proxy.Credentials = CredentialCache.DefaultCredentials;
string Input = string.Empty;
try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
using (StreamReader sr = new StreamReader(response.GetResponseStream()))
{
Input = sr.ReadToEnd();


ajit machhePosted Mar 12, 2017, 4:14 AM
Its not working when i try to use linkedin ? could you plz assist the direction to look ?
Ahmar HusainPosted Nov 20, 2013, 4:34 AM
I think WebClient class and its DownloadString method is much easier to use .
asp learnerPosted Aug 26, 2013, 7:00 AM
HI.. UR ARTICLE IS NICE.. could you tell me how to login to the webpage using httpwebrequest
polas andersonPosted Mar 11, 2012, 2:06 PM
Hi your code not working i do know why but it doea not work when i try to seek for emails it drops me this program turn off in the seconds. Why is this happining ?
Michael BrummettPosted Jan 20, 2011, 1:26 PM
Your example is very helpful but I am also not able to unzip the download.
Kurt BankPosted Jan 19, 2011, 10:51 AM
Liked the article. Like the title. Download file says it's invalid though.
laks_winPosted Jan 18, 2011, 12:05 AM
Article is nice. Reckon, the titles "Email scraping" or "Web page content scraping" would be fine