read a web page

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Is there anyway to read a Web page and do a search for a particular word or
section on the web page?


I have a web page that reads a queue that has docs from many apps, I want to
search the web page and only get docs related to my app and create a text
file with the names of the doc in the queue. Is that possible via C#?

thx
 
Hi Mike,

Sure it is possible. One way to do it is to use HttpWebRequest,
HttpWebResponse and a StreamReader.

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
StreamReader reader = new StreamReader(resp.GetResponseStream());
string webpage = reader.ReadToEnd();

For extracting the information from the page, you might use IndexOf or
Regex expressions.


Happy coding!
Morten Wennevik [C# MVP]
 
Back
Top