The URLSearchParams interface defines utility methods to work with the query string of a URL.
Project description
URLSearchParams
The URLSearchParams interface defines utility methods to work with the query string of a URL.
URLSearchParams().getAll()
The getAll() method of the URLSearchParams interface returns all parameter as an array.
Syntax
URLSearchParams().getAll()
Examples
from URLSearchParams import URLSearchParams
src = URLSearchParams("https://www.google.com?q=python")
print(src.getAll())
>>> ['q=python']
URLSearchParams().get()
The get() method of the URLSearchParams interface returns the first value associated to the given search parameter.
Syntax
URLSearchParams(url).get(name)
Examples
from URLSearchParams import URLSearchParams
src = URLSearchParams("https://www.google.com?q=python")
print(src.get("q"))
>>> 'python'
URLSearchParams().append()
The append() method of the URLSearchParams interface appends a specified key/value pair as a new search parameter.
Syntax
URLSearchParams(url).append({name : value})
Examples
from URLSearchParams import URLSearchParams
src = URLSearchParams("https://www.google.com?q=python")
print(src.append({"lang" : "en"}))
>>> 'https://www.google.com?q=python&lang=en'
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
URLSearchParams-1.2.tar.gz
(2.9 kB
view hashes)
Built Distribution
Close
Hashes for URLSearchParams-1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 333d94f104d5ca1d34816dc311efd348aa5157e2956b8ecdb19f97db038b4081 |
|
MD5 | bdb1ee0fa9e47957c24c0c026cf1c5fa |
|
BLAKE2b-256 | 840f44a5b3455ecb48e7610386b44b838dd6356eb17d11dfe4d344b6a54d99e0 |