tags:

views:

330

answers:

1

Hi,

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

How can i access Wiki. Please give some suggestion

+5  A: 

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