Not Another Google Search
Not another Google searching library. Just kidding - it is.
Made for educational purposes. I hope it will help!
Table of Contents
How to Install
Standard Install
pip3 install nagooglesearch
pip3 install --upgrade nagooglesearch
Build and Install From the Source
git clone https://github.com/ivan-sincek/nagooglesearch && cd nagooglesearch
python3 -m pip install --upgrade build
python3 -m build
python3 -m pip install dist/nagooglesearch-8.7-py3-none-any.whl
Usage
Standard
Default values:
nagooglesearch.GoogleClient(
tld = "com",
homepage_parameters = {
"btnK": "Google+Search",
"source": "hp"
},
search_parameters = {
},
cookies = {
},
user_agent = "",
proxy = "",
max_results = 100,
min_sleep = 8,
max_sleep = 18,
debug = False
)
Only domains without they keyword google and not ending with the keyword goo.gl are accepted as valid results. The final output is a unique and sorted list of URLs.
Google frequently changes cookies, so default ones might not work; specify new ones using the cookies parameter.
Default cookies can be found here.
Example, standard:
import nagooglesearch
# the following query string parameters are set only if 'start' query string parameter is not set or is equal to zero
# simulate a homepage search
homepage_parameters = {
"btnK": "Google+Search",
"source": "hp"
}
# search the internet for additional query string parameters
# https://brightdata.com/blog/web-data/google-search-url-parameters
search_parameters = {
"q": "site:*.example.com intext:password", # search query
"tbs": "li:1", # specify 'li:1' for verbatim search (no alternate spellings, etc.)
"hl": "en",
"lr": "lang_en",
"cr": "countryUS",
"udm": "14", # only web results
"filter": "0", # specify '0' to display hidden results
"safe": "images" # specify 'images' to turn off safe search, or specify 'active' to turn on safe search
}
# if the default cookies no longer work, specify new ones here
# if left empty, the default ones will be used
cookies = {
}
client = nagooglesearch.GoogleClient(
tld = "com", # top level domain, e.g., www.google.com or www.google.hr
homepage_parameters = homepage_parameters, # 'search_parameters' will override 'homepage_parameters'
search_parameters = search_parameters,
cookies = cookies,
user_agent = "curl/3.30.1", # a random user agent will be set if none is provided
proxy = "socks5://127.0.0.1:9050", # supported URL schemes are 'http[s]', 'socks4[h]', and 'socks5[h]'
max_results = 200, # maximum unique URLs to return
min_sleep = 15, # minimum sleep between page requests
max_sleep = 30, # maximum sleep between page requests
debug = True # enable debug output
)
urls = client.search()
if client.get_error() == nagooglesearch.Error.REQUEST:
print("[ Request Exception ]")
# do something
elif client.get_error() == nagooglesearch.Error.RATE_LIMIT:
print("[ HTTP 429 Too Many Requests ]")
# do something
for url in urls:
print(url)
# do something
Check the list of user agents here. For more user agents, check scrapeops.io.
Shortest Possible
Example, shortest possible:
import nagooglesearch
urls = nagooglesearch.GoogleClient(search_parameters = {"q": "site:*.example.com intext:password"}).search()
# do something
Time Sensitive Search
Example, do not show results older than 6 months:
import nagooglesearch, dateutil.relativedelta as relativedelta
def get_tbs(months: int):
today = datetime.datetime.today()
return nagooglesearch.get_tbs(today, today - relativedelta.relativedelta(months = months))
search_parameters = {
"tbs": get_tbs(6)
}
# do something
User Agents
Example, get all user agents:
import nagooglesearch
user_agents = nagooglesearch.get_all_user_agents()
print(user_agents)
# do something
Example, get a random user agent:
import nagooglesearch
user_agent = nagooglesearch.get_random_user_agent()
print(user_agent)
# do something
Metadata
Release files for nagooglesearch 8.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nagooglesearch-8.7.tar.gz | 6.9 kB | Without provenance | Details for nagooglesearch-8.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nagooglesearch-8.7-py3-none-any.whl | Python 3 | none | any | Details for nagooglesearch-8.7-py3-none-any.whl |
Total release size: 13.9 kB
Release files / nagooglesearch-8.7.tar.gz
| Download URL | nagooglesearch-8.7.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c25419e36544538c82d0310885de7d98818719fd45a069c092cfd0854c078b19
|
|
BLAKE2b-256 checksum How to use checksums |
f859e3d536bf54723933e74d025455aa246029815925db3e54d777ba5fa8a74a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.8
|
Release files / nagooglesearch-8.7-py3-none-any.whl
| Download URL | nagooglesearch-8.7-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1e3a260b24e17014f5216d7ecf600c73ed226f28557028059beb4b416e030397
|
|
BLAKE2b-256 checksum How to use checksums |
d8b5f96c9acc10fd82dde545170425c218c9ca8ecab9c5dae4db48b735a063d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.8
|
Security for nagooglesearch 8.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.