维基百科api是python
mediawikiapi的Python项目详细描述
MediaWikiAPI
mediawikiapi是一个易于访问和分析的python库 维基百科的数据。
搜索维基百科,获取文章摘要,获取链接和图片等数据
从一页,等等。维基百科将MediaWiki API <https://www.mediawiki.org/wiki/API>
包装起来,这样您就可以专注于使用
维基百科的数据,不知道。
>>>frommediawikiapiimportMediaWikiAPI>>>mediawikiapi=MediaWikiAPI()>>>printmediawikiapi.summary("Wikipedia")# Wikipedia (/ˌwɪkɨˈpiːdiə/ or /ˌwɪkiˈpiːdiə/ WIK-i-PEE-dee-ə) is a collaboratively edited, multilingual, free Internet encyclopedia supported by the non-profit Wikimedia Foundation...>>>mediawikiapi.search("Barack")# [u'Barak (given name)', u'Barack Obama', u'Barack (brandy)', u'Presidency of Barack Obama', u'Family of Barack Obama', u'First inauguration of Barack Obama', u'Barack Obama presidential campaign, 2008', u'Barack Obama, Sr.', u'Barack Obama citizenship conspiracy theories', u'Presidential transition of Barack Obama']>>>ny=mediawikiapi.page("New York (state)")>>>ny.title# u'New York (state)'>>>ny.url# u'http://en.wikipedia.org/wiki/New_York_(state)'>>>ny.content# u'New York is a state in the northeastern United States. New York was one of the original thir'...>>>ny.links[0]# u'1790 United States Census'>>>mediawikiapi.config.language="fr">>>mediawikiapi.summary("Facebook",sentences=1)# Facebook est un service de réseautage social en ligne sur Internet permettant d'y publier des informations (photographies, liens, textes, etc.) en contrôlant leur visibilité par différentes catégories de personnes.
安装
要安装MediaWikiAPI,只需运行:
pip install mediawikiapi
MediaWikiAPI与Python3和Python2.7兼容。
更改日志
Changelog可以在文档中找到。
文档
文档可用here
要运行测试,请克隆repository on GitHub <https://github.com/lehinevych/MediaWikiAPI>
,然后运行:
pip install -r requirements.txt bash runtests # will run tests for python and python3 python -m unittest discover tests/ '*test.py'# manual style
在根项目目录中。
要自行构建文档,请在安装requirements.txt之后运行:
pip install sphinx
cd docs/
make html
许可证
麻省理工学院许可。参见LICENSE file <https://github.com/lehinevych/MediaWikiAPI/blob/master/LICENSE>
全部细节。
学分
- @戈德史密斯制作了如此棒的图书馆