Skip to main content

httpx with css.

Project description

httpc

Sponsoring Hits PyPI - Downloads image image Ruff uv

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.6.0: Remove deprecated parameters, remove ClientOptions
  • 0.5.0: Use Lexbor as default backend, fix and improve retry and raise_for_status
  • 0.4.0: Fix incorrect type hint, rename CSSTool to ParseTool, CSSResponse to Response, bugfixes and small improvements
  • 0.3.0: Add new parameter, remove select method, rename css to match from 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


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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

httpc-0.7.0-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file httpc-0.7.0.tar.gz.

File metadata

  • Download URL: httpc-0.7.0.tar.gz
  • Upload date:
  • Size: 109.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.16

File hashes

Hashes for httpc-0.7.0.tar.gz
Algorithm Hash digest
SHA256 32410e937dcb4b99ebe2e86280321a43d4f830b981565f701f57317d82584928
MD5 33b1fc68a2d12b115fb195ab9bc7ff71
BLAKE2b-256 985ba594a560f28ee1a3799c5d253179005a0ad995609d4af48d130e21ccd312

See more details on using hashes here.

File details

Details for the file httpc-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: httpc-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.16

File hashes

Hashes for httpc-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 855346d1f1e2c9ceec960eb3a943a71fe96359748c0f2fc7f571a04f95667858
MD5 d720f9ca8580e6dcac1a19afa86f183b
BLAKE2b-256 a78b4abd2dde341b31150cd7ec454dfabb116072cc873b936dc54d5791d71d41

See more details on using hashes here.

Supported by

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