Skip to main content

Simple pure Python Google URL generator based on google(.com) advanced search.

Project description

Google URL Builder.

Simple pure Python Google URL generator based on Google advanced search.

Why?

In some development cases, you may need to generate Google search URLs without the wish to request Google(.com).

In example :

  • for displaying/providing those URLs directly to the end user.
  • to have more control over what your code makes.

Package principles.

  • Pure Python → No more depedencies needed.
  • Strong typing.

Examples.

Import package.

from googleurlbuilder import (
    GoogleURL,
    SearchFilters,
    parameters as pr, # Aliases are optionnal.
    # Query parameters.
    operators as op,
    # Operators over query parameters.
    filters as ft,
    # Filters.
)

Simple use case.

url = GoogleURL((pr.Words(["search", "google"]) + pr.ExactPhrases(["google search"])))

print(url.compute_url())
https://google.com/search?q=%28%28search+google%29+%22google+search%22%29

Use filters.

url = GoogleURL(
    query=pr.Words(["search", "google"]),
    filters=SearchFilters(language=ft.Languages.French),
    tld="fr",
)

print(url.compute_url())
https://google.fr/search?lr=lang_fr&q=%28search+google%29

Use operators over search parameters.

query = op.Or(pr.Words(["search"]), pr.ExactPhrases(["google"]))
print(query)
query = pr.Words(["search"]) | pr.ExactPhrases(["google"])  # equivalent.
print(query)
(search OR "google")
(search OR "google")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

googleurlbuilder-0.1.0.tar.gz (11.2 kB view hashes)

Uploaded Source

Built Distribution

googleurlbuilder-0.1.0-py3-none-any.whl (11.6 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