Python URL Parser
A nice package to help you parse all types of URL's in vanilla python and return the parsed URL in groups.
Version 2.1 also included get_base_url a small yet neat function to get a the main url back from a string
Installation
pip install hi-urlparser
Usage
from hiurlparser import parse_url, get_base_url
url = parse_url('https://open.prospecta.app/my_user_login?user=hi-urlparser&password=H3ll0') # returns url sections as a dict
url_object = get_url('https://open.prospecta.app/my_user_login?user=hi-urlparser&password=H3ll0') # Does the same, bur returns a object
basic_url = get_base_url('https://open.prospecta.app/my_user_login?user=hi-urlparser&password=H3ll0') # Returns just the main url
print(url['domain']) # Outputs -> prospecta
print(url_object.domain) # Outputs -> prospecta
print(basic_url) # Outputs -> https://open.prospecta.app
Keywords parse_url
When using the parse_url function, you get a dict back with different parts of the URL.
The different parts can be accessed by keywords:
For parse_url use: result['top_domain]
Here is a list of all the available keywords:
| Keyword | Desription | Value when not present in URL |
|---|---|---|
| protocol | The protocol, e.g. https or ftp | None |
| www | Returns www if www is used in the URL | None |
| sub_domain | The sub domain, e.g. my.subdomain in my.subdomain.example.com. Note that the sub domain also includes www. | None |
| domain | The domain, e.g. example in example.com | Is always present |
| top_domain | The domain, e.g. com in example.com | Is always present |
| dir | The directory, e.g. /my/directory/ in example.com/my/directory/ | None |
| file | The file, e.g. my_file.js in example.com/home/my_file.js | None |
| path | The full path, e.g. /home/my_file.js in example.com/home/my_file.js | None |
| fragment | The URL fragment, e.g. my_link in example.com#my_link | None |
| query | The URL query, e.g. my_parameter=1&foo=bar in example.com?my_parameter=1&foo=bar | None |
Testing
Use the following command to run tests.
python -m unittest hiurlparser.tests.test_url_parser
Changelog:
See CHANGELOG.md
Metadata
Release files for hi-urlparser 3.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hi-urlparser-3.0.4.tar.gz | 77.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hi_urlparser-3.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 155.4 kB
Release files / hi-urlparser-3.0.4.tar.gz
| Download URL | hi-urlparser-3.0.4.tar.gz |
|---|---|
| Size | 77.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b4eb17b6a1485128bfd2150da2480e44fa6d775c25a5dbb0a7df56d7b010d2e
|
|
BLAKE2b-256 checksum How to use checksums |
b611d01615f8b06f9bd689ce88dbd787d15134d09f2e0aeb4d232c4542945184
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
|
Release files / hi_urlparser-3.0.4-py3-none-any.whl
| Download URL | hi_urlparser-3.0.4-py3-none-any.whl |
|---|---|
| Size | 77.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5989371f4841e4bea210e25e434903980b031729708c36313058daffe40cbb72
|
|
BLAKE2b-256 checksum How to use checksums |
ed9a3bef41a6bf6c1feb39e3b5830d6488ad4bd00c49d953342531ae9c64efa2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
|