[python]分享一个好用的python的wiki库——Wikipedia API
最近需要要爬一些维基百科上的内容,试用了好几个python的库,发现了一个特别好用的,整理一下,分享给大家。
一开始用的是wikipedia这个库,但是不知道是我电脑配置问题还是这个库已经不维护了,运行的时候都会被服务器拒绝。
所以转而就试了Wikipedia-API这个库。
https://pypi.org/project/Wikipedia-API/
这是一个打包好了的,用来调取维基百科api的python库,对于要爬维基的朋友来说,非常有用啦~~
简单的翻一下文档,供大家参考:
安装:
pip3 install wikipedia-api
//import:
import wikipediaapi
//选择语言(如果选择中文则将en改为zh)
wiki_wiki = wikipediaapi.Wikipedia('en')
//获取关键词的页面
page_py = wiki_wiki.page(“关键词”)
//确认关键词页面是否存在
page_py .exists()
//获取页面标题
page_py.title
//获取页面概述
page_py.summary
//获取页面上的其他分类信息
page_py.sections
另外这个库还可以查看页面的其他链接、按分类查看等等功能;更具体的可以去库的主页查看:
https://github.com/martin-majlis/Wikipedia-API
你那里天气如何?还在发愁自己的好文没人发现,收益惨淡吗?记得加上cn-curation标签,让飞鸽传书 帮你走出困境吧!假如我的留言打扰到你,请回复“取消”。
Congratulations @littlexiannv! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word
STOP
Do not miss the last post from @steemitboard:
Congratulations @littlexiannv! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word
STOP
Do not miss the last post from @steemitboard:
Congratulations @littlexiannv! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word
STOP
Do not miss the last post from @steemitboard:
Congratulations @littlexiannv! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word
STOP
Congratulations @littlexiannv! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word
STOP
Congratulations @littlexiannv! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Vote for @Steemitboard as a witness to get one more award and increased upvotes!