PageRenderTime 57ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/searchapi/duckduckgo.py

https://bitbucket.org/agiliq/searchapi
Python | 16 lines | 14 code | 2 blank | 0 comment | 2 complexity | 0aec9d8572b9243af86c9245f9c886e6 MD5 | raw file
  1. import urllib
  2. try:
  3. import json
  4. except ImportError:
  5. import simplejson as json
  6. class Duck(object):
  7. def __init__(self):
  8. self.end_point='http://api.duckduckgo.com/?q='
  9. def duckduckgo(self,query):
  10. query_string = urllib.quote_plus(query)
  11. final_url = self.end_point + query_string + '&format=json&pretty=1'
  12. response = urllib.urlopen(final_url)
  13. data = json.load(response)
  14. return data