Skip to main content

A python API for Web Purify

Project description

pip install python_purify

or:

python setup.py install

Examples

Setup

from python_purify import WordPurify
from python_purify import ImagePurify
...
purify = WordPurify(my_api_key)
imgpurify = ImagePurify(my_img_api_key)
vidpurify = VideoPurify(my_img_api_key)

The Web Purify default response type is XML, but JSON is normally better to work with. We made JSON the standard format for our package, but you can set it to XML with the rspformat variable:

purify = WordPurify(my_api_key, rspformat='xml')

This will return a cElementTree object. If you want to use a better package like beautiful soup, you can return the tree back to text with the following:

from xml.etree import cElementTree as ET
...
out = purify.check('Some nice words')
xml_string = ET.tostring(out)
# Some other XML parser can load the data now.

Initialization options

  • live - Default: True. If false, uses the webpurify sandbox

  • rspformat - Default: ‘json’. Can be set to ‘json’ or ‘xml’

  • verbose - Default: False. If true, prints the WebPurify url before making a request.

WordPurify Methods

Once setup if finished, you can simply call each method:

out = purify.check('Some nice words')
print out
# {u'rsp': {u'@attributes': {u'stat': u'ok'}, u'found': u'0', u'api_key': u'*********', u'method':  u'webpurify.live.check', u'format': u'rest'}}

The following WordPurify methods are included:

Note:

you should be able to set most of the options in the function call except for format. Format is determined at WordPurify creation. In this example, rsp=1 will give us the response time and slink=1 will tell WebPurify to flag urls:

purify.check('Some nice words', rsp=1, slink=1)

ImagePurify Methods

Just like with WordPurify, once setup, you can call the ImagePurify Methods.

out = imgpurify.img_account()

The following ImagePurify methods are included:

VideoPurify

VideoPurify works in much the same way as ImagePurify.

out = vidpurify.vid_account()

The following ImagePurify methods are included:

Testing

We have written some basic tests for python 2.7 and python 3.

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

python_purify-2.0.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

python_purify-2.0.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file python_purify-2.0.1.tar.gz.

File metadata

  • Download URL: python_purify-2.0.1.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for python_purify-2.0.1.tar.gz
Algorithm Hash digest
SHA256 abf6be0e8403fdeba62553c9cd9a3f0ffd5cce1a58db170a62599c02f5cc9a29
MD5 8635194d23670e98f7276a2301c903f9
BLAKE2b-256 42b33e4c6ea3a65b71236caec0dd25ad95e429ac90b79c312fb6e776a67f0ed9

See more details on using hashes here.

File details

Details for the file python_purify-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: python_purify-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for python_purify-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b7506ec69ee25edb0d4cc48ee3e29c51d4259d3dff8cf2539d14a4c007642ddc
MD5 bf824a2ea9f7b2a0c8238f56e28fb650
BLAKE2b-256 3495e9418dfcc33e16f7116934a83e0034b76b8b8a0e168fc61572af84fbc942

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