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...