Bee Eee Blog

c# Reading the contents of a web page

by brian on Sep.10, 2008, under .NET, c#, coding

Reading the contents of a web page can be very useful.  Here’s some code I’m developing to read the historical stock prices from http://finance.google.com

string uri = "http://finance.google.com/finance/historical?cid=667226&startdate=Sep+9%2C+2007&enddate=Sep+10%2C+2008&output=csv";
WebRequest request = WebRequest.Create(uri);
WebResponse response = request.GetResponse();
var stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream, Encoding.GetEncoding("utf-8"));
string page = reader.ReadToEnd();

There you go. Very simple isn’t it? Just got to love .Net

:, ,
No comments for this entry yet...

Comments are closed.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...