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. Install them and run:
$ python tests/testall.py
Releasing
Pushing a version tag publishes the package to PyPI with Trusted Publishing and creates a GitHub Release. The tag must match urlfetch.__version__ (for example v2.0.1).
git tag vX.Y.Z git push origin vX.Y.Z
Release notes come from the matching section in doc/changelog.rst, followed by GitHub’s auto-generated notes. sdist and wheel are attached to the release.
One-time PyPI setup (project owner)
On https://pypi.org/manage/project/urlfetch/settings/publishing/ add a GitHub Trusted Publisher:
Owner: ifduyue
Repository: urlfetch
Workflow: publish.yml
Environment: pypi
The GitHub environment pypi is restricted to tags matching v*. No PyPI API token is stored in the repository.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file urlfetch-2.0.3.tar.gz.
File metadata
- Download URL: urlfetch-2.0.3.tar.gz
- Upload date:
- Size: 73.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7913c2509727ae2ebcc6ac189b13e10c417a84409edc849854a5d1edf7f55884
|
|
| MD5 |
0c0bc85ec4095550f32129cf876e4a1b
|
|
| BLAKE2b-256 |
275565b8b5af5c9de93fe871dc226b89a84b7ecfef6af6abfd37feacb0ee2cbe
|
Provenance
The following attestation bundles were made for urlfetch-2.0.3.tar.gz:
Publisher:
publish.yml on ifduyue/urlfetch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
urlfetch-2.0.3.tar.gz -
Subject digest:
7913c2509727ae2ebcc6ac189b13e10c417a84409edc849854a5d1edf7f55884 - Sigstore transparency entry: 2581272316
- Sigstore integration time:
-
Permalink:
ifduyue/urlfetch@661d5073e710ea46934403a6774adba02bea35f4 -
Branch / Tag:
refs/tags/v2.0.3 - Owner: https://github.com/ifduyue
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@661d5073e710ea46934403a6774adba02bea35f4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file urlfetch-2.0.3-py3-none-any.whl.
File metadata
- Download URL: urlfetch-2.0.3-py3-none-any.whl
- Upload date:
- Size: 70.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f7c4a3b804070b900d665ba5317f2c257469242e514b7a73bd0f3de812bac5f
|
|
| MD5 |
92a961f157b40d1ee95095bb4dd60720
|
|
| BLAKE2b-256 |
f75838fc8c471c2ffe8b35d50a1be1a0652f84baf1a50c87e953c9149f744686
|
Provenance
The following attestation bundles were made for urlfetch-2.0.3-py3-none-any.whl:
Publisher:
publish.yml on ifduyue/urlfetch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
urlfetch-2.0.3-py3-none-any.whl -
Subject digest:
6f7c4a3b804070b900d665ba5317f2c257469242e514b7a73bd0f3de812bac5f - Sigstore transparency entry: 2581272339
- Sigstore integration time:
-
Permalink:
ifduyue/urlfetch@661d5073e710ea46934403a6774adba02bea35f4 -
Branch / Tag:
refs/tags/v2.0.3 - Owner: https://github.com/ifduyue
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@661d5073e710ea46934403a6774adba02bea35f4 -
Trigger Event:
push
-
Statement type: