纽约时报文章搜索 API 的 Python 包装器
项目描述
NYTimesArticleAPI是纽约时报文章搜索 API的全功能 Python 包装器。
安装
用点子:
$ pip install NYTimesArticleAPI
依赖项
NYTimesArticleAPI 需要 `requests < https://pypi.python.org/pypi/requests >`__ 和 `setuptools < https://pypi.python.org/pypi/setuptools >`__ 包。
用法
只需使用您的开发人员密钥导入和初始化 API:
>>> from NYTimesArticleAPI import articleAPI
>>> api = articleAPI("YourAPIKey")
然后使用所需的搜索参数/值调用搜索函数:
>>> articles = api.search(q="Obama",
fq={"headline": "Obama",
"source": ["Reuters",
"AP",
"The New York Times"]},
begin_date="20161023", # this can also be an int
facet_field=["source", "day_of_week"],
facet_filter=True)
搜索函数返回搜索结果的 Python 字典。
您可以使用字典指定多个过滤器:
.. code:: python
>>> fq = {"headline": "Obama", "source": ["Reuters", "AP", "The New York Times"]}
以及使用列表的多个值:
.. code:: python
>>> facet_field = ["source", "day_of_week"]
更多示例:
>>> articles = api.search(q="Obama")
>>> articles = api.search(q="Obama", begin_date="20111231", page=2)
有关可用搜索参数的完整概述,请参阅NYTimes 文章搜索 API 文档。
历史
这个包最初由Evan Sherlock编写为 `nytimesarticle < https://github.com/evansherlock/nytimesarticle >`__。此后,它由Matt Morrison分叉和更新,随后发布为 `NyTimesArticleAPI < https://pypi.python.org/pypi/NYTimesArticleAPI >`__,由Gerald Spencer 和Andrew Han贡献。
执照
© 2016 马特·莫里森mattdmo @ pigimal 。com。
这是免费软件。它是根据MIT License获得许可的。随意在您自己的工作中使用它。但是,如果您修改和/或重新分发它,请以某种方式归于我,并在此或类似许可下分发您的作品。大喊大叫或啤酒将不胜感激。
项目详情
关
NYTimesArticleAPInew -1.0.0.tar.gz 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 0fcf4f8151431bd3221bdebfdc7c70fb4caecf04b0fe9f04852927810f3a213c |
|
| MD5 | 43ea07f37d1208d50d0ad57990342af7 |
|
| 布莱克2-256 | dff610db10a78a44f93107b780e4826a8c8f1532398ecd78955367c5fcfec629 |