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-2.1.0a0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48a3a642e12d212c365b0d7c59301945c949e9754836db05a8bea9a9ed329eca |
|
MD5 | 203bb149f2f5cd3ec9e80bc155df53ea |
|
BLAKE2b-256 | 9ca64802db2d3e5b69650d1059dfabac27ade7a2ba2f2e6e362e568d063a0ed7 |
Close
Hashes for google_custom_search-2.1.0a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4491da2e5d5d41eb3ec1cd42883364b85459b7302601a0d2cae1ce1d1ed70882 |
|
MD5 | d3bea95eb5854c219b8559019ed2ec1e |
|
BLAKE2b-256 | 6fa9127d6c3b3bf481c1fcf6e68c88cb028ed721333ed7b4882fa339a622ac56 |