Skip to main content

An asynchronous Google Search Engine API wrapper

Project description

cse.py

Asyncio API wrapper for the Google Custom Search JSON API.

Installation

PIP

pip install -U cse.py

GIT

pip3 install -U git+https://github.com/Hype3808/cse.py

Usage

import cse

client = cse.Engine("Your API Key") # create the Search client (uses Google by default!)

results = await client.search("Python", safesearch=False) # returns a list of cse.Result objects

print(results[0].title, results[0].description, results[0].url, results[0].image_url) # Title, snippet, URL, and Image URL

await client.close() # Run this when cleaning up.

Getting image results

import cse

client = cse.Engine("Your API Key") # create the Search client (uses Google by default!)

results = await client.search("Python", safesearch=False, image_search=True) # returns a list of cse.Result objects

print(results[0].title, results[0].description, results[0].url, results[0].image_url) # Title, snippet, URL, and Image URL

await client.close() # Run this when cleaning up.

To use Search objects with a custom search engine, provide the ID of the search engine.

cse.Engine("Your API Key", engine_id="015786823554162166929:mywctwj8es4")

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.

Get API key

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cse.py-1.1.3.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

cse.py-1.1.3-py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page