This is for google custom search api.
Project description
google-custom-search
Install
pip install google-custom-search
or if you want use async/await, please install.
pip install google-custom-search[async]
Sample code
import google_custom_search
google = google_custom_search.CustomSearch(apikey="your api_key", engine_id="your engine_id")
# if image is True, it's can search, but you need to setting at google console search
results = google.search("Hello")
for result in results:
# get a title.
print(result.title)
# get a link.
print(result.url)
# get a displayLink.
print(result.display_url)
# get a htmlTitle.
print(result.html_title)
# get a snippet.
print(result.snippet)
Sample code async version
import asyncio
import google_custom_search
google = google_custom_search.CustomSearch(token="your api_key", engine_id="your engine_id", image=True)
# if image is True, it's can search, but you need to setting at google console search
async def main():
results = await google.search_async("word!")
for result in results:
# get a title.
print(result.title)
# get a link.
print(result.url)
# get a displayLink.
print(result.display_url)
# get a htmlTitle.
print(result.html_title)
# get a snippet.
print(result.snippet)
asyncio.run(main())
or
import asyncio
import google_custom_search
google = google_custom_search.CustomSearch(token="your api_key", engine_id="your engine_id", image=True)
# if image is True, it's can search, but you need to setting at google console search
async def main():
async for item in google.search_async_iterator("word!"):
# get a title.
print(item.title)
# get a link.
print(item.url)
# get a displayLink.
print(item.display_url)
# get a htmlTitle.
print(item.html_title)
# get a snippet.
print(item.snippet)
asyncio.run(main())
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
Built Distribution
Close
Hashes for google-custom-search-3.0.0a0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa8cacaa30c7e7ef9005d5d8dbc11f59f711f9691692aba0338d3615ece9ee8d |
|
MD5 | 45627e9203b63771c3b96f92a44c3335 |
|
BLAKE2b-256 | ed82ed257f4329b6367688f7a8f25646afa23841e2fd755f6be3adb7fb2f44ec |
Close
Hashes for google_custom_search-3.0.0a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cddc4091d281df1463258e5243628490792c3677e7d7f30d2774005bc8bc18a |
|
MD5 | de21f1e112ac20b7250870705e1024d3 |
|
BLAKE2b-256 | c670ac71866ea155de18ef07c68a8dfb26b61f84801de32bfb717a1335ad0343 |