Skip to main content

An easy to use HTTP client

Project description

urlfetch is a simple, lightweight and easy to use HTTP client for Python. It is distributed as a single file module and has no depencencies other than the Python Standard Library.

Highlights

  • Distributed as a single file module, has no depencencies other than the Python Standard Library.

  • Pure Python, works fine with gevent.

  • Small codebase, about 1000 lines and 30% are comments and blank lines. Only 10 minutes you can know every detail.

  • Random user-agent.

  • Support streaming.

Installation

$ pip install urlfetch

Hello, world

import urlfetch

response = urlfetch.get('http://python.org/')
print response.status, response.reason
print len(response.content)

Uploading files

import urlfetch

response = urlfetch.post(
    'http://127.0.0.1:8888/upload',
    headers = {
        'Referer': 'http://127.0.0.1/',
    },
    files = {
        'fieldname1': open('/path/to/file', 'rb'),
        #'fieldname2': 'file content', # file must have a filename
        'fieldname3': ('filename', open('/path/to/file2', 'rb')),
        'fieldname4': ('filename', 'file content'),
    },
    data = {
        'foo': 'bar'
    },
)

print response.status, response.content

Testing

To run the tests, urlfetch relies on bottle and gunicorn. If the tests are run by calling python setup.py test, the dependencies will be handled automatically (via tests_require). So, if you want to run the tests directly, that is, python tests/testall.py, make sure bottle and gunicorn are installed under the PYTHONPATH.

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

urlfetch-1.2.1.tar.gz (68.6 kB view details)

Uploaded Source

File details

Details for the file urlfetch-1.2.1.tar.gz.

File metadata

  • Download URL: urlfetch-1.2.1.tar.gz
  • Upload date:
  • Size: 68.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for urlfetch-1.2.1.tar.gz
Algorithm Hash digest
SHA256 a0516d33a7fcf38b8ccebcf343365cbfa4239b6d37b34ab95bf56d3121e2de3a
MD5 9e58765c9947c96bbaec95c2d929ea45
BLAKE2b-256 50d420a6629180ecef6ebe7b2ec408318c879e9b249b6761897a9776a1d6daef

See more details on using hashes here.

Supported by

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