Skip to main content

Python client for the Diffbot API.

Project description

Bitdeli Build Status Coverage Status Version Downloads

How to use it:

>>> import diffbot
>>> json_result = diffbot.article('https://github.com', token='…')

The above simple example is a shortcut for using the diffbot.Client class.

>>> import diffbot
>>> client = diffbot.Client(token='…')
>>> json_result = client.article('https://github.com')

The above calls are shortcuts for using the diffbot.api() function and the diffbot.Client.api method:

>>> import diffbot
>>> client = diffbot.Client(token='…')
>>> json_result = client.api('article', 'https://github.com')

To POST data (text or HTML) to the API, use the text or html arguments:

>>> 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>
... ''')

Command line interface:

$ 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' or 'analyze'.
  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

Output of the above example:

{
  "icon": "https://github.com:443/apple-touch-icon-144.png",
  "sections": [
      
  ],
  "title": "Build software better, together.",
  "url": "https://github.com/"
}

Features:

  • Python 2+3 support

  • Google App Engine support

  • Requests support (but no dependency)

  • CI + 100% test coverage

  • Passes pyflakes, pep8, flake8, pylint score 10/10

  • Simple & small (1 file, ~100 LOC)

  • Command line interface

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diffbot-1.1.2.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file diffbot-1.1.2.tar.gz.

File metadata

  • Download URL: diffbot-1.1.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for diffbot-1.1.2.tar.gz
Algorithm Hash digest
SHA256 4611ac1285bf9dad3c3fe4529f820d7737f3b68f5879f82dba639ac749a169b9
MD5 1c127b7245277360a898cb6b57ab482a
BLAKE2b-256 a312e48a3912ab6270316008d7b45b26b5d575c34cc9c300b2430146cb10413d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page