

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An asp.net application code example for screen scraping using regular expressions. The application allows users to input a url and a search pattern, then it scrapes the html content and returns the matched results. The document also includes a c# class named screenscrape with methods for getting html content from a url and parsing it using a regular expression.
Typology: Study notes
1 / 3
This page cannot be seen from the preview
Don't miss anything!


<%@ Page Language="C#" ValidateRequest="false" %> <%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %>
Screen Scraping
Simple Screen Scraper
Target Page URL:
Regular expression search pattern:
Display HTML Scrape using regular expression
using System; using System.Web; using System.Net; using System.IO; using System.Text.RegularExpressions; /// /// Summary description for ScreenScraping /// public class ScreenScrape { private int _ItemCount = 0; public int ItemCount { get { return _ItemCount; } } public string GetHTML(string URL) { WebResponse myResponse; WebRequest myRequest; StreamReader myStreamReader; string strHTML = ""; try { myRequest = System.Net.HttpWebRequest.Create(URL); myRequest.Timeout = 6000; //milliseconds myResponse = myRequest.GetResponse(); myStreamReader = new StreamReader(myResponse.GetResponseStream()); strHTML = myStreamReader.ReadToEnd(); myStreamReader.Close(); } catch (Exception ex) { throw new Exception(ex.Message); } return strHTML; } public string ParseHTML(string HTML, string Pattern)