Furl is a Python library designed for simple and powerful manipulation of URLs. It provides an object-oriented interface to parse, modify, and generate URLs, allowing easy access and modification of schemes, hosts, paths, query parameters, and fragments. The current version is 2.1.4, and it generally follows an as-needed release cadence for bug fixes and minor improvements, with major versions indicating significant API changes.
pip install furlVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a `furl` object, access and modify its various components (scheme, host, path, query, fragment), and use methods like `join()` to combine URLs.
Upgrade your Python environment to 3.8 or newer, or pin furl to a version less than 2.1.4.
Assign the result of the operation back to the variable (e.g., `f = f / 'segment'`) or use the in-place assignment operator (`f /= 'segment'`).
Be aware of this behavior change when using `furl.join()` with scheme-like relative URLs on Python 3.9 and newer. Test your URL joining logic if it relies on specific edge cases.
Ensure your applications rely on ampersands (`&`) as the standard query delimiter. If consuming URLs with semicolon delimiters, consider pre-processing or adapting parsing logic to convert them to ampersands if needed.
Install the 'furl' library using pip: `pip install furl` or `python -m pip install furl`.
Ensure the host string contains only valid characters (alphanumeric, hyphens, periods) and does not include scheme, username, password, or port information. If assigning a full netloc, it should be parsed correctly, or set individual components like `f.host`, `f.port`, etc. For example, `f.host = 'example.com'` instead of `f.host = 'user:pass@example.com'`.
Assign an integer between 1 and 65535 (inclusive) or `None` to the `port` attribute. For example: `f.port = 8080` or `f.port = None`.
Do not directly set `f.path.isabsolute = False` if the `furl` object has a `netloc`. If you need a relative path with a netloc, consider if your URL structure is logically correct. If you want a relative path, ensure the `furl` object does not have a `netloc` set or construct the relative path separately. For example: `f = furl('/relative/path')` or clear the netloc first: `f.netloc = ''` before modifying `f.path.isabsolute`.Always provide a scheme for absolute URLs to ensure correct parsing of host and port. For example: `furl('http://127.0.0.1:8080/a/b')` or `furl('//127.0.0.1:8080/a/b')` for a protocol-relative URL.