Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google search API used by willie is deprecated #650

Closed
drwn opened this issue Oct 25, 2014 · 3 comments
Closed

Google search API used by willie is deprecated #650

drwn opened this issue Oct 25, 2014 · 3 comments

Comments

@drwn
Copy link

drwn commented Oct 25, 2014

The search API willie is used is deprecated and does not work. See: https://developers.google.com/web-search/docs/

I'm not sure for who it does and doesn't work, but for me it doesn't. And apparently for other people as well, judging by the conversations on IRC.

@randomessence
Copy link

1: It works as it it currently, so I would assume your problem is elsewhere. Try it on a Digital Ocean Droplet and see.

2: You have to pay for the custom search api queries past 100 uses per day.

3: It requires Google CSE/Google Dev accounts

I used with with willie but it involves a unique identifiers per user from Google CSE/Google Dev accounts and in the end it didn't actually work as expected, but here is what I use (modified for relevance)

You can add this to your search.py and reload. It should work

trigger = .cse

MYKEY = You APi key from Google Dev

MYCSEID = You Search engine ID from Google CSE

Note: It is just showing how I modified the existing code to work with CSE.

def google_cse(query):
    uri = 'https://www.googleapis.com/customsearch/v1'
    args = '?key=MYKEY&cx=MYCSEID&googlehost=https://google.co.uk&num=1&lr=lang_en&q=' + query
    bytes = web.get(uri + args)
    return json.loads(bytes)

def google_search_cse(query):
    results = google_cse(query)
    try:
        if results['queries']['request'][0]['totalResults'] == '0':
            results = ''
        else:
            return results['items'][0]['link']
    except IndexError:
        return None
    except TypeError:
        return False

@commands('cse')
@example('.cse swhack')
def cse(bot, trigger):
    """Queries Google for the specified input."""
    query = trigger.group(2)
    if not query:
        return bot.reply('.cse what?')
    uri = google_search_cse(query)
    if uri:
        bot.reply(uri)
        if 'last_seen_url' in bot.memory:
            bot.memory['last_seen_url'][trigger.sender] = uri
    elif uri is False:
        bot.reply("Problem getting data from Google.")
    else:
        bot.reply("No results found for '%s'." % query)

I had better results with https://swiftype.com/ for custom searches

@drwn
Copy link
Author

drwn commented Oct 26, 2014

This seems to be an IPv6 issue, at least for me. Upon disabling IPv6 I could use the Google module without any problems. Enabled IPv6 and it gave me the same error, I even tried it out on several servers -- all of them gave me the same error. They were all Linode servers.

elad661 pushed a commit that referenced this issue Dec 19, 2014
Google removed their deprecated API we used for searching.
Since their new API requires API keys (and sometimes money), it's
simply not worth the hassle to support. Duck Duck Go should be good
enough.

This fixes issue #650, in a way.
@elad661
Copy link
Contributor

elad661 commented Dec 19, 2014

Google finally killed off their old api. I wouldn't want to force users to register API keys to use such basic functionaltity, so I aliased .g to .ddg instead. Feel free to submit your .cse command as a pull request for willie-extras.

@elad661 elad661 closed this as completed Dec 19, 2014
elad661 pushed a commit that referenced this issue Dec 19, 2014
Google removed their deprecated API we used for searching.
Since their new API requires API keys (and sometimes money), it's
simply not worth the hassle to support. Duck Duck Go should be good
enough.

This fixes issue #650, in a way.
maxpowa pushed a commit to maxpowa/Inumuta that referenced this issue Feb 20, 2015
Google removed their deprecated API we used for searching.
Since their new API requires API keys (and sometimes money), it's
simply not worth the hassle to support. Duck Duck Go should be good
enough.

This fixes issue sopel-irc#650, in a way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants