pyfaup-rs

raw JSON →
0.4.6 verified Fri May 01 auth: no python

Python bindings for faup-rs, a Rust library for fast URL parsing and normalization. Current version 0.4.6, Python >=3.8, active development on GitHub.

pip install pyfaup-rs
error ModuleNotFoundError: No module named 'pyfaup'
cause Trying to import 'pyfaup' instead of 'faup'.
fix
Use 'from faup import faup'.
error AttributeError: 'NoneType' object has no attribute 'host'
cause For relative URLs or invalid input, parse_url may return None.
fix
Check the result before accessing attributes: result = parser.parse_url(url); if result: print(result.host)
gotcha The library uses 'faup' as the module name, not 'pyfaup'. Many users incorrectly import 'pyfaup'.
fix Use 'from faup import faup' instead.
gotcha The parser only parses URLs; it does not validate or encode/decode them. Invalid URLs may raise an exception.
fix Ensure URLs are well-formed. Handle exceptions when parsing.

Parse a URL and access components.

from faup import faup

parser = faup()
result = parser.parse_url("https://example.com/path?q=1#frag")
print(result.scheme, result.host, result.port, result.path, result.query, result.fragment)