由于原始仓库自2014年以来已被废弃,因此更新了`wikipedia`包的版本。
项目描述
Wikipedia
NLPiA2-Wikipedia Wikipedia API的薄Python包装器
搜索Wikipedia,获取文章摘要,从页面获取数据如链接和图片等。Wikipedia包装了MediaWiki API,这样您可以专注于使用Wikipedia数据,而不是获取数据。
>>> from wikipedia import wikipedia as wiki
>>> print wiki.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...
>>> wiki.search("Barack")
['Barak (given name)', 'Barack Obama', ... 'Presidential transition of Barack Obama']
>>> titles = wiki.search("New York")
>>> page = wiki.page(titles[1])
>>> page.title
'New York (State)'
>>> page.url
'http://en.wikipedia.org/wiki/New_York_(state)'
>>> page.content
'New York, sometimes called New York State...'
>>> page.summary
'New York, sometimes called New York State...'
>>> page.links[0]
'10 Hudson Yards'
>>> wiki.set_lang("fr")
>>> wiki.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.
(或其它更高级的Python MediaWiki API包装器),它具有更大的API、速率限制和其他功能,这样我们可以考虑MediaWiki基础设施。
安装
要安装Wikipedia,只需运行
$ pip install nlpia2-wikipedia
维基百科兼容Python 2.6+(2.7+ 用于运行 unittest discover)和Python 3.3+。
文档
请参阅文档:[https://wikipedia.readthedocs.org/en/latest/](https://wikipedia.readthedocs.org/en/latest/)
要运行测试,请在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
许可证
采用MIT许可。有关详细信息,请参阅LICENSE文件。
鸣谢
- Wikipedia
- Pywikipediabot
- @richardasaurus的wiki-api
- 维基媒体基金会(为全球提供免费知识访问)
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分布
nlpia2_wikipedia-1.5.17.tar.gz (15.7 kB 查看哈希)
构建分布
nlpia2_wikipedia-1.5.17-py3-none-any.whl (15.5 kB 查看哈希)
关闭
nlpia2_wikipedia-1.5.17.tar.gz的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 049812a54d7e90655bbff4a62ee7400c05f762d773e0cd8990db7056886a9f10 |
|
MD5 | ef9269f5e7b250fca99588801971d6bf |
|
BLAKE2b-256 | 458fc6d64b6fe1f68c59807e0839565f7ffbcdf8e59d6cad20b417882b86eaec |
关闭
nlpia2_wikipedia-1.5.17-py3-none-any.whl的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 8b0d3b01f2a36668a066dc1e5cc3b065528a54d008deae810702649e90e68311 |
|
MD5 | 3281ffcda388af4bf3f5e20d11e0d6c2 |
|
BLAKE2b-256 | 169875d111b70bf4bef8016dd45064cdca82b7d476a3d50c6551de8d67310d32 |