simpleclient
simpleclient "Python Simple HTTP Client" is a simple guzzle-like library built on top of The Standard Python Library. Unlike guzzle, simpleclient is smaller, and not full of features. It is compatible with Python 2.x and 3.x. There is also a php-simple-client written in PHP.
Install
pip install simpleclient
Quick Start
import simpleclient
client = simpleclient.Stream()
Simple GET
Send a GET Request
client.seturl('https://www.google.com/') # required to set an url
client.send()
Display Responses
print(client.getheader())
# HTTP/1.1 200 OK
# Date: Mon, 14 Jan 2021 14:14:48 GMT
# Expires: -1
# Cache-Control: private, max-age=0
# Content-Type: text/html; charset=UTF-8
# ...
print(client.getheader(0))
# HTTP/1.1 200 OK
print(client.getheader('Content-Type'))
# text/html; charset=UTF-8
print(client.getbody())
# <!doctype html>...</html>
Custom Requests
Custom requests using the request() method.
client.seturl('https://www.google.com/') # required to set an url
client.request('HEAD')
client.send()
You can also provide a payload, for example, for a POST request. The payload can be a dictionary, or a string. It will automatically send a 'Content-Type: application/x-www-form-urlencoded' header. You can set it manually with the setheaders() method for other types required.
client.request('POST', {'user': 'myusername', 'pass': 'mypassword'})
Setting Headers To Be Sent
Setting Headers must be done before calling request() and send() method.
client.setheaders([
'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0',
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language: en-US,en;q=0.5'
])
Common
print(client.getprotocol()) # HTTP
print(client.getprotocolversion()) # 1.1
print(client.getstatuscode()) # 200
print(client.getreasonphrase()) # OK
Debug
You can enable debug mode. This will allow you to monitor the request header being sent.
client = simpleclient.Stream(debug=True)
client.seturl('https://www.google.com/') # required to set an url
client.request('HEAD')
client.send()
# finally, show the response
print(client.getheader())
And other features to hack like the getresponse() method.
Metadata
Release files for simpleclient 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| simpleclient-0.0.5.tar.gz | 4.7 kB | Without provenance | Details for simpleclient-0.0.5.tar.gz |
Release files / simpleclient-0.0.5.tar.gz
| Download URL | simpleclient-0.0.5.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
37cfbe31e223e931e6d705c3f7c413c68a4eb83609dd09a4948d31ad616eb015
|
|
BLAKE2b-256 checksum How to use checksums |
828202243eb6c1813347efbee45a74fcd11e7a844b9dbcbb609d8dcb94b7a106
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9
|
Security for simpleclient 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.