Python's `urllib2`: Why do I get error 403 when I `urlopen` a Wikipedia page?

前端 未结 6 1179
轻奢々
轻奢々 2020-12-07 11:07

I have a strange bug when trying to urlopen a certain page from Wikipedia. This is the page:

http://en.wikipedia.org/wiki/OpenCola_(drink)

This

6条回答
  •  眼角桃花
    2020-12-07 11:35

    As Jochen Ritzel mentioned, Wikipedia blocks bots.

    However, bots will not get blocked if they use the PHP api. To get the Wikipedia page titled "love":

    http://en.wikipedia.org/w/api.php?format=json&action=query&titles=love&prop=revisions&rvprop=content

提交回复
热议问题