{ "info": { "author": "Seth Michael Larson", "author_email": "sethmichaellarson@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Internet" ], "description": "# whatwg-url\n\n[![Travis](https://img.shields.io/travis/SethMichaelLarson/whatwg-url/master.svg)](https://travis-ci.org/SethMichaelLarson/whatwg-url)\n[![Codecov](https://img.shields.io/codecov/c/github/SethMichaelLarson/whatwg-url/master.svg)](https://codecov.io/gh/SethMichaelLarson/whatwg-url)\n[![PyPI](https://badge.fury.io/py/whatwg-url.svg)](https://pypi.org/project/whatwg-url)\n\nPython implementation of the [WHATWG URL Living Standard](https://url.spec.whatwg.org/).\n\nThe latest revision that this package implements of the standard is August 7th, 2018 ([`commit 49060c7`](https://github.com/whatwg/url/commit/49060c74d3047602a572f9e88a6a1101f4fd32f3))\n\n## Getting Started\n\nInstall the `whatwg-url` package using `pip`.\n\n`python -m pip install whatwg-url`\n\nAnd use the module like so:\n\n```python\nimport whatwg_url\n\nurl = whatwg_url.parse_url(\"https://www.google.com\")\nprint(url)\n# Url(scheme='https', hostname='www.google.com', port=None, path='', query='', fragment='')\n```\n\n## Features\n\n### Compatibility with `urllib.parse.urlparse()`\n\n```python\nimport whatwg_url\n\nparseresult = whatwg_url.urlparse(\"https://seth:larson@www.google.com:1234/maps?query=string#fragment\")\n\nprint(parseresult.scheme) # 'https'\nprint(parseresult.netloc) # 'www.google.com:1234'\nprint(parseresult.userinfo) # 'seth:larson'\nprint(parseresult.path) # '/maps'\nprint(parseresult.params) # ''\nprint(parseresult.query) # 'query=string'\nprint(parseresult.fragment) # 'fragment'\nprint(parseresult.username) # 'seth'\nprint(parseresult.password) # 'larson'\nprint(parseresult.hostname) # 'www.google.com'\nprint(parseresult.port) # 1234\nprint(parseresult.geturl()) # 'https://seth:larson@www.google.com:1234/maps?query=string#fragment'\n```\n\n### URL Normalization\n\nThe WHATWG URL specification describes methods of normalizing URL inputs to usable URLs.\nIt handles percent-encodings, default ports, paths, IPv4 and IPv6 addresses, IDNA (2008 and 2003), multiple slashes after scheme, etc.\n\n```python\nimport whatwg_url\n\nprint(whatwg_url.normalize_url(\"https://////www.google.com\")) # https://www.google.com\nprint(whatwg_url.normalize_url(\"https://www.google.com/dir1/../dir2\")) # https://www.google.com/dir2\nprint(whatwg_url.normalize_url(\"https://\u4f60\u597d\u4f60\u597d\")) # https://xn--6qqa088eba/\nprint(whatwg_url.normalize_url(\"https://\uff10\uff38\uff43\uff10\uff0e\uff10\uff12\uff15\uff10\uff0e\uff10\uff11\")) # https://192.168.0.1/\n```\n\n### URL Validation\n\n```python\nprint(whatwg_url.is_valid_url(\"https://www.google.com\")) # True\nprint(whatwg_url.is_valid_url(\"https://www .google.com\")) # False\n```\n\n### Relative URLs\n\nHTTP redirects often contain relative URLs (via the `Location` header) that need to be applied to the current URL location.\nSpecifying the `base` parameter allows for giving relative URLs as input and the changes be applied to a new `URL` object.\n\n```python\nimport whatwg_url\n\nurl = whatwg_url.parse_url(\"../dev?a=1#f\", base=\"https://www.google.com/maps\")\nprint(url.href) # https://www.google.com/dev?a=1#f\n```\n\n### URL Property Mutators\n\nModifying properties on a `URL` object use the parser and \"state overrides\" to properly mutate the `URL` object.\n\n```python\nurl = whatwg_url.parse_url(\"http://www.google.com:443\")\n\nprint(url.scheme) # 'http'\nprint(url.port) # 443\n\nurl.scheme = 'https'\n\nprint(url.scheme) # 'https'\nprint(url.port) # None\n```\n\n### \"Splatable\"\n\nThe module is a single file which allows for easy vendoring into projects.\n\n## License\n\n[Apache-2.0](https://github.com/SethMichaelLarson/whatwg-url/blob/master/LICENSE)\n\n\n# Changelog\n\n## 2018.8.26\n\n### Added\n\n- Added `UrlParser` and `Url`\n- Added `UrlParser.parse_host()`\n- Added `UrlParser.parse_ipv4_host()`\n- Added `Url.origin`\n- Added `Url.authority`\n- Added `urlparse` and `urljoin` to be compatible with\n [`urllib3.parse.urlparse`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlparse)\n and [`urllib.parse.urljoin`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)\n- Added support for Python 2.7, 3.4, and 3.5", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/SethMichaelLarson/whatwg-url", "keywords": "", "license": "Apache-2.0", "maintainer": "", "maintainer_email": "", "name": "whatwg-url", "package_url": "https://pypi.org/project/whatwg-url/", "platform": "", "project_url": "https://pypi.org/project/whatwg-url/", "project_urls": { "Homepage": "https://github.com/SethMichaelLarson/whatwg-url" }, "release_url": "https://pypi.org/project/whatwg-url/2018.8.26/", "requires_dist": null, "requires_python": "", "summary": "Python implementation of the WHATWG URL Living Standard", "version": "2018.8.26" }, "last_serial": 4209352, "releases": { "2018.8.26": [ { "comment_text": "", "digests": { "md5": "4850c9eed025f946bbfd19c3f618ea2f", "sha256": "a4d59cc99bf6ab5967f140316dd9bb4daf6cdb18581895ef423dd54f7b41f43b" }, "downloads": -1, "filename": "whatwg-url-2018.8.26.tar.gz", "has_sig": false, "md5_digest": "4850c9eed025f946bbfd19c3f618ea2f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30373, "upload_time": "2018-08-26T22:39:57", "url": "https://files.pythonhosted.org/packages/36/34/c001514dbe3cc0bf6022dde46a56dc21c3e3f8208036baf8ab995a3df7a3/whatwg-url-2018.8.26.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4850c9eed025f946bbfd19c3f618ea2f", "sha256": "a4d59cc99bf6ab5967f140316dd9bb4daf6cdb18581895ef423dd54f7b41f43b" }, "downloads": -1, "filename": "whatwg-url-2018.8.26.tar.gz", "has_sig": false, "md5_digest": "4850c9eed025f946bbfd19c3f618ea2f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30373, "upload_time": "2018-08-26T22:39:57", "url": "https://files.pythonhosted.org/packages/36/34/c001514dbe3cc0bf6022dde46a56dc21c3e3f8208036baf8ab995a3df7a3/whatwg-url-2018.8.26.tar.gz" } ] }