用于python的wikipedia api

wikipedia的Python项目详细描述


https://travis-ci.org/goldsmith/Wikipedia.png?branch=masterhttps://pypip.in/d/wikipedia/badge.pnghttps://pypip.in/v/wikipedia/badge.pngLicense

wikipedia是一个易于访问和解析的python库 维基百科的数据。

搜索维基百科,获取文章摘要,获取链接和图片等数据 从一页,等等。维基百科将MediaWiki API包装起来,这样您就可以专注于使用 维基百科的数据,不知道。

>>>importwikipedia>>>printwikipedia.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...>>>wikipedia.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=wikipedia.page("New York")>>>ny.title# u'New York'>>>ny.url# u'http://en.wikipedia.org/wiki/New_York'>>>ny.content# u'New York is a state in the Northeastern region of the United States. New York is the 27th-most exten'...>>>ny.links[0]# u'1790 United States Census'>>>wikipedia.set_lang("fr")>>>wikipedia.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.

注意:这个库是为简单易用而设计的,不是为高级使用而设计的。如果您计划执行严重的刮擦或自动请求,请使用Pywikipediabot(或其他更高级的Python MediaWiki API wrappers),它具有更大的api、速率限制和其他功能,因此我们可以考虑mediawiki基础设施。

安装

要安装Wikipedia,只需运行:

$ pip install wikipedia

wikipedia与python 2.6+(运行unittest discover的是2.7+)和python 3.3+兼容。

文档

阅读https://wikipedia.readthedocs.org/en/latest/上的文档。

要运行测试,请克隆respository on GitHub,然后运行:

$ 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了解 全部细节。

学分

  • wiki-api作者 @Richardasaurus的灵感
  • @nmoroze和@themichaelyang提供反馈和建议
  • 给予的Wikimedia Foundation 全球免费访问数据
Bitdeli badge

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何修复无法解析从未使用过的符号和变量的错误   java lucene搜索   java无法获取可用的提供程序解析程序   java问题使用引发SAXException的方法编译类   是否可以编辑抽象类?JAVA   java AppletViewer出现错误并试图加入计时器   基于java JNI的Android库,在没有NDK的情况下使用   Java如何使用Jenkins中的环境变量?   XMLHttpRequestJavaJavaScript   JPA实体中的java枚举类型字段   java泛型方法将一种枚举类型转换为另一种枚举类型   java Liveconnect小程序问题   java SpringBoost应用程序和Apache Ignite配置:启动ApplicationContext时出现问题   反射从Java8中的类对象获取方法引用   调试时Eclipse在java 8类加载器上中断