2

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

How can i access Wiki. Please give some suggestion

Luke Quinane
  • 16,447
  • 13
  • 69
  • 88

1 Answers1

7

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();
Himadri
  • 8,600
  • 15
  • 47
  • 70
  • 6
    ...and, of course, respect the copyright (http://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License). – T.J. Crowder Oct 13 '09 at 13:22