Welcome to AspAdvice Sign in | Join | Help

Retrieving a Web Page in a Different Language

Recently I needed to get the text from a web page that was in a different language. I used encoding when reading the page with StreamReader. This worked well, just make sure you use the right encoding.

string url = "http://se.yahoo.com";
string data = "";
System.Net.WebResponse WebResponse1;
System.Net.WebRequest WebRequest1 = System.Net.HttpWebRequest.Create(url);
System.Text.Encoding Encoding1 = System.Text.Encoding.GetEncoding("windows-1252");
WebResponse1 = WebRequest1.GetResponse();
using (System.IO.StreamReader StreamReader1 =
new System.IO.StreamReader(WebResponse1.GetResponseStream(),Encoding1))
{
data = StreamReader1.ReadToEnd();
StreamReader1.Close();
}

Sponsor
Published Monday, October 04, 2004 7:08 AM by andrewmooney

Comments

No Comments

Anonymous comments are disabled