async-cse
Asyncio API wrapper for the Google Custom Search JSON API.
Installation
Want stable releases?
pip3 install -U async_cse
Living on the edge? Want hotfixes?
pip3 install -U git+https://github.com/crrapi/async-cse
Usage
import async_cse
client = async_cse.Search("Your API Key") # create the Search client (uses Google by default!)
results = await client.search("Python", safesearch=False) # returns a list of async_cse.Result objects
first_result = results[0] # Grab the first result
print(first_result.title, first_result.description, first_result.url, first_result.image_url) # Title, snippet, URL, and Image URL (if specified)
await client.close() # Run this when cleaning up.
Getting image results
To get image results with the default engine, use image_search=True when searching, like so:
await client.search("Python", safesearch=False, image_search=True) # returns a list of async_cse.Result objects
Custom search engines
To use Search objects with a custom search engine, provide the ID of the search engine.
async_cse.Search("Your API Key", engine_id="015786823554162166929:mywctwj8es4")
SafeSearch
SafeSearch can also be turned off by setting safesearch=False when using the search() method.
Getting an API key
You can get an API key by going here and scrolling down to the API key section.
(New in 0.3.0) API Key Shuffling
Key shuffling may be used as a fail-safe for keys that run out of requests, effectively giving you +100 requests for each key passed.
Just pass a list of keys when instantiating your Search client.
Here's a demonstration of this:
import async_cse
client = async_cse.Search(["API Key 1", "API Key 2", "API Key 3"]) # Multiple keys as a list
await client.search("Python") # Uh oh, one of these keys doesn't work! Trying again with another...
When async-cse detects a non-working key, it will remove it from its internal list and retry the search.
Metadata
Release files for async-cse 0.3.0
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 |
|---|---|---|---|---|
| async_cse-0.3.0.tar.gz | 5.1 kB | Without provenance | Details for async_cse-0.3.0.tar.gz |
Release files / async_cse-0.3.0.tar.gz
| Download URL | async_cse-0.3.0.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fcb7c25331cb6fd410d1483b7b3ae0e3dd3cb8f071efbdffdb56082e4dee9859
|
|
BLAKE2b-256 checksum How to use checksums |
bcd1c9a6827d0ec7108853ce9e902d3c047495c7f5d358e5ebfe148dc381a4eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1
|
Security for async-cse 0.3.0
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.