Question

I want to access HTML content from wikipedia .But it is showing access denied.

How can i access Wiki. Please give some suggestion

Was it helpful?

Solution

Use HttpWebRequest

Try the following:

string Text = "http://www.wikipedia.org/";
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(Text);
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)";
HttpWebResponse respons;
respons = (HttpWebResponse)request.GetResponse();
Encoding enc = Encoding.GetEncoding(respons.CharacterSet);
StreamReader reader = new StreamReader(respons.GetResponseStream(), enc);
string sr = reader.ReadToEnd();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top