Skip to main content

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

This version

1.2

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)

Uploaded Source

Built Distribution

URLSearchParams-1.2-py3-none-any.whl (2.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page