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.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19eba56480f627520fea5514b0d790fc681bf3bedb318f0233742d8b3093541e |
|
MD5 | 3d78258dd37fbadb42523f8f3afab4e0 |
|
BLAKE2b-256 | b4e410acaabbeaaaa5f343c4050c10e4791f90fbac8a08813b9eebc10b9f0481 |
Close
Hashes for google_custom_search-2.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd22ed21a9e4820fa81f73f1e879635f241ea93ef59567c535f3a39b67cd1d5a |
|
MD5 | 2b34156042f66792a89796cc98622d6f |
|
BLAKE2b-256 | 8877aa8f38ea36cca73dcd8fb156e79aeb0c5f8d1e1d2e0c9019c16909ee03c4 |