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-2.0.1.tar.gz (67.1 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: urlfetch-2.0.1.tar.gz
  • Upload date:
  • Size: 67.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.2

File hashes

Hashes for urlfetch-2.0.1.tar.gz
Algorithm Hash digest
SHA256 bc1e60a71b2c6177b25830dda39daf2a230b6ce11c7bf2186098a785523adaa5
MD5 fa7c5b06245c6e2eca7eb215c58f49a9
BLAKE2b-256 bba1e1d6b044af47c9ccda8b04b8b03c78faec238f7fadac3526f2ce86205033

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