bbayles / what-url

URL parser and manipulator based on the WHAT WG URL standard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

what-url

This is what_url, a Python library for parsing and joining URLs.

The library uses the WHATWG URL standard for parsing. It uses CFFI to wrap the ada C/C++ library. This project is not affiliated with either of those.

Installation

Install from pip:

pip install what-url

Examples

>>> import what_url
>>> what_url.check_url('https://example.org')
True
>>> what_url.join_url(
    'https://example.org/dir/child.txt', '../parent.txt'
)
'https://example.org/parent.txt'
>>> what_url.normalize_url('https://example.org/dir/../parent.txt')
'https://example.org/parent.txt'
>>> what_url.parse_url('https://user:pass@example.org:80/api?q=1#2')
{
    'href': 'https://user:pass@example.org:80/api?q=1#2',
    'username': 'user',
    'password': 'pass',
    'protocol': 'https:',
    'host': 'example.org:80',
    'port': '80',
    'hostname': 'example.org',
    'pathname': '/api',
    'search': '?q=1',
    'hash': '#2'
}

About

URL parser and manipulator based on the WHAT WG URL standard

License:Apache License 2.0


Languages

Language:C++ 98.4%Language:Python 1.2%Language:C 0.3%Language:Makefile 0.1%