相关疑难解决方法(0)

使用Python获取Wikipedia文章

我尝试使用Python的urllib获取维基百科文章:

f = urllib.urlopen("http://en.wikipedia.org/w/index.php?title=Albert_Einstein&printable=yes")           
s = f.read()
f.close()
Run Code Online (Sandbox Code Playgroud)

然而,而不是HTML页面,我得到以下响应:错误 - 维基媒体基金会:

Request: GET http://en.wikipedia.org/w/index.php?title=Albert_Einstein&printable=yes, from 192.35.17.11 via knsq1.knams.wikimedia.org (squid/2.6.STABLE21) to ()
Error: ERR_ACCESS_DENIED, errno [No Error] at Tue, 23 Sep 2008 09:09:08 GMT 
Run Code Online (Sandbox Code Playgroud)

维基百科似乎阻止了不是来自标准浏览器的请求.

有谁知道如何解决这个问题?

python user-agent wikipedia urllib2 http-status-code-403

39
推荐指数
3
解决办法
3万
查看次数