Hacker News new | ask | show | jobs
by andai 265 days ago
That's the one I use, yeah! You set it up here:

https://programmablesearchengine.google.com/controlpanel/cre...

And then it's just a GET:

    import os
    import json
    from req import get

    url = "https://customsearch.googleapis.com/customsearch/v1"

    def search(query):
        data = {
            "q": query,
            "cx": os.getenv('GOOGLE_SEARCH_API_KEY'),
            "key": os.getenv('GOOGLE_SEARCH_API_ID')
        }
        results_json = get(url, data)
        results = json.loads(results_json)
        results = results["items"]
        return results