This is for google custom search api.
Project description
google-custom-search
How to use this package.
Next version can search image.
first please install this package
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-2.0.7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c42959b9e288247c8a59d585b9d8c6c07cb0ffbfc700066d4ec78d9497534e83 |
|
MD5 | 4cd665b7806709e19c8a319005409ad1 |
|
BLAKE2b-256 | 510a303d9034b09c656ac5b5b0971eb3ea35db0c628e4eccbd82ecf3614b6564 |
Close
Hashes for google_custom_search-2.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 070a1c89180a4d1719aa4044e03875de052ea8d1cc8a7423d1fd1c949842ae0f |
|
MD5 | ecab683265657102d4d99c0d653ef464 |
|
BLAKE2b-256 | 6d8e4bd7a5bf603554ceb9545e7aee6b1d53b0fa2fbdec9bafee1dc96b94069e |