Diffbot API的Python客户端。
项目描述
如何使用它
>>> import diffbot
>>> json_result = diffbot.article('https://github.com', token='…')
上面的简单示例是使用diffbot.Client类的快捷方式。
>>> import diffbot
>>> client = diffbot.Client(token='…')
>>> json_result = client.article('https://github.com')
上面的调用是使用diffbot.api()函数和diffbot.Client.api方法的快捷方式
>>> import diffbot
>>> client = diffbot.Client(token='…')
>>> json_result = client.api('article', 'https://github.com')
要将数据(文本或HTML)POST到API,请使用text或html参数
>>> import diffbot
>>> client = diffbot.Client(token='…')
>>> json_result = client.api('article', 'https://github.com', html='''
... <h1>Introducing GitHub Traffic Analytics</h1>
... <p>We want to kick off 2014 with a bang, so today we're happy to launch
... traffic analytics!</p>
... ''')
命令行界面
$ python diffbot.py -h
usage: diffbot.py [-h] [-a] [-f FILE] api url token
positional arguments:
api API to call. One one of 'article', 'frontpage',
'product', 'image', 'analyze' or 'discussion'.
url URL to pass as the 'url' parameter.
token API key (token). Get one at https://www.diffbot.com/.
optional arguments:
-h, --help show this help message and exit
-a, --all Request all fields.
-f FILE, --file FILE File to read data from. Use '-' to read from STDIN.
$ python diffbot.py article https://github.com TOKEN
上述示例的输出
{
"icon": "https://github.com:443/apple-touch-icon-144.png",
"sections": [
…
],
"title": "Build software better, together.",
"url": "https://github.com/"
}
功能
Python 2+3支持
Google App Engine支持
Requests支持(但无依赖项)
通过pyflakes、pep8、flake8、pylint评分10/10
简单 & 小型(1文件,<200LOC)
命令行界面
项目详情
关闭
diffbot-2.0.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 4595e8ab49f3ec83371393a3830b71079ea3f44dc3425960fb6941cb2a87121b |
|
MD5 | 69579a9f5a1ec507b1133465ee30d8ff |
|
BLAKE2b-256 | 582a1ce67e6c321c3747994eef325afe433641baacd9071cbe7a6902fb147890 |