httpx with css.
Project description
httpc
httpx with CSS
Installation
pip install -U httpc
Examples
>>> import httpc
>>> response = httpc.get("https://www.python.org/")
>>> response.match("strong") # CSS Matching
[<Node strong>, <Node strong>, <Node strong>]
>>> response.match("strong").bc.text() # Broadcasting
['Notice:', 'A A', 'relaunched community-run job board']
>>> response.single("div") # .single() method
ValueError: Query 'div' matched with 47 nodes (error from 'https://www.python.org/').
>>> response.single("div", remain_ok=True) # .single() method
<Node div>
>>> response.single("#content")
<Node div>
>>> httpc.get("https://python.org")
<Response [301 Moved Permanently]>
>>> httpc.common.get("https://python.org") # ClientOptions and httpc.common
<Response [200 OK]>
>>> httpc.common.get("https://hypothetical-unstable-website.com/", retry=5) # retry parameter
Attempting fetch again (ConnectError)...
Attempting fetch again (ConnectError)...
Successfully retrieve 'https://hypothetical-unstable-website.com/'
<Response [200 OK]>
>>> httpc.get("https://httpbin.org/status/400")
<Response [400 BAD REQUEST]>
>>> httpc.get("https://httpbin.org/status/400", raise_for_status=True) # raise_for_status as parameter
httpx.HTTPStatusError: Client error '400 BAD REQUEST' for url 'https://httpbin.org/status/400'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400
>>> httpc.get("https://httpbin.org/status/500", raise_for_status=True, retry=3)
Attempting fetch again (status code 500)...
Attempting fetch again (status code 500)...
Attempting fetch again (status code 500)...
httpx.HTTPStatusError: Server error '500 INTERNAL SERVER ERROR' for url 'https://httpbin.org/status/500'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500
Release Note
- 0.4.0: Fix incorrect type hint, rename CSSTool to ParseTool, CSSResponse to Response, bugfixes and small improvements
- 0.3.0: Add
newparameter, removeselectmethod, renamecsstomatchfrom CSSTool, remove cache_api.py (unused script), add url note, retry if server error on raise_for_status, bugfix - 0.2.0: Initial release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
httpc-0.5.0.tar.gz
(105.7 kB
view details)
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
httpc-0.5.0-py3-none-any.whl
(12.1 kB
view details)
File details
Details for the file httpc-0.5.0.tar.gz.
File metadata
- Download URL: httpc-0.5.0.tar.gz
- Upload date:
- Size: 105.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.29
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f499a51b0e9e68b73e440c68434ba6eef4f69bf2287f511db2e3d6e552dd169
|
|
| MD5 |
7bdbd8b1793b2efef51e4241d937a589
|
|
| BLAKE2b-256 |
396e422e57a24b25795278629c10c09a3b66ecda147a21084ce8b498c7ffae12
|
File details
Details for the file httpc-0.5.0-py3-none-any.whl.
File metadata
- Download URL: httpc-0.5.0-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.29
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfa70099590138e322e1d94b5ebc8095f94a468fc1a242d14e454a7a17bdf22b
|
|
| MD5 |
1b11cbb472c23e20af3e98500fde08b5
|
|
| BLAKE2b-256 |
7c669cc4d5ea82a4718647f5d89ee00d05bd6a47b5031fb2b30e3d24b2504e3d
|