Basic Example
import asyncio
import cse
import os
from dotenv import load_dotenv # pip install python-dotenv
# your .env file
# CSE_API_KEY = your_api_key
load_dotenv()
api_key = os.getenv('CSE_API_KEY')
engine = cse.Engine(api_key)
async def main():
result = await engine.search("query", safesearch=True, image_search=True)
print(result[0].title) # title of the query you search for
print(result[0].description) # short description of your query
print(result[0].url) # url of your query
try:
print(result[0].image_url) # image url of the query you search
except:
return # if will not print the image url if no image were found in the query
asyncio.get_event_loop().run_until_complete(main())