How to access wikipedia

匿名 (未验证) 提交于 2019-12-03 07:50:05

问题:

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

How can i access Wiki. Please give some suggestion

回答1:

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(); 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!