0

I would love a nice, friendly example to help me out, or even a link to help me get started.

I'm baffled by google's "cloud application" interface and none of the search tutorials seem to readily point to vanilla google search. It seems they are overcomplicating and obfuscating.

I have a google dev account and I'm just trying to figure out what commands to put into python to get a search and return the URLs as a list like you can do in xgoogle, but more friendly to google and not liable to get banned.

Tim Hoffman
  • 12,976
  • 1
  • 17
  • 29
Pinwheeler
  • 1,061
  • 2
  • 13
  • 26

1 Answers1

1

Google Web Search API has deprecated, so Google AJAX API is recommended.

You can custom your search like this:

import json
import urllib2

search_line = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=hello'
response = urllib2.urlopen(search_line)
search_results = json.loads(response.read())
print(search_results['responseData']['results'])
ziggear
  • 886
  • 7
  • 22
  • This answer is probably correct, but I think I need a wider answer to really understand how to make this work. I'm happy to read, but I don't know the correct starting point or what to google for. Should I be googling for json? for google ajax api? – Pinwheeler Dec 10 '13 at 23:04
  • To clarify, where would I go to learn how to format the search_line variable so that I know exactly what the rules are to be able to search for anything. Right now I can't search for multi-word queries – Pinwheeler Dec 10 '13 at 23:07
  • update, figured out %20 is the way to add a space in a search. Is there a place to go to learn about all of the other "escape sequences"? – Pinwheeler Dec 10 '13 at 23:45
  • Watching [Google AJAX API](http://developers.google.com/custom-search/v1/using_rest). Special characters should be encoded before sending to url, there is a reference [URL encoding in python](http://stackoverflow.com/questions/8905864/url-encoding-in-python) @Pinwheeler – ziggear Dec 12 '13 at 02:34
  • This API is no longer available, the alternative is [google-custom-search](https://developers.google.com/custom-search/). – ands Aug 28 '17 at 14:28