Beispiel #1
0
 def search_google(self, terms):
     params = {'v': '1.0', 'q' : terms}
     googleurl = 'http://ajax.googleapis.com/ajax/services/search/web'
     search_results = loadUrl(googleurl, params)
     json = simplejson.loads(search_results)
     results = json['responseData']['results']
     return results
Beispiel #2
0
 def search_wikipedia(self, terms, lang='sv'):
     searchurl = 'http://%s.wikipedia.org/w/api.php' % lang
     linkurl = 'http://%s.wikipedia.org/wiki/%s'
     params = { 'action': 'opensearch', 'search': terms, 'format': 'json' }
     search_results = loadUrl(searchurl, params)
     json = simplejson.loads(search_results)
     (searchedterm, termlist) = json
     results = list(dict( title = title, url = linkurl % (lang, urllib.quote(title)) ) for title in termlist)
     return results