PageRenderTime 1ms CodeModel.GetById 100ms app.highlight 2ms RepoModel.GetById 79ms app.codeStats 0ms

/searchapi/duckduckgo.py

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