The above was solved in PHP with the help of Google AJAX Search API. Since I am a big proponent of Python, here is the equivalent Pythonic version:
import json, urllib
BASE = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&'
keywords = 'django'
url = BASE + urllib.urlencode({'q': keywords})
results = json.load(urllib.urlopen(url))
response_data = results['responseData']
results = response_data['results']
# Show the url from the first search result
print results[0]['visibleUrl']
Not all of the search results gave me the exact url for the store names but 98% of the job was done automatically, the suspicious ones can be eyeballed and corrected.
No comments:
Post a Comment