Fetch a Wikipedia article with Python

前端 未结 10 1889
余生分开走
余生分开走 2020-11-27 15:37

I try to fetch a Wikipedia article with Python\'s urllib:

f = urllib.urlopen(\"http://en.wikipedia.org/w/index.php?title=Albert_Einstein&printable=yes\")         


        
10条回答
  •  粉色の甜心
    2020-11-27 16:21

    It is not a solution to the specific problem. But it might be intersting for you to use the mwclient library (http://botwiki.sno.cc/wiki/Python:Mwclient) instead. That would be so much easier. Especially since you will directly get the article contents which removes the need for you to parse the html.

    I have used it myself for two projects, and it works very well.

提交回复
热议问题