This commit is contained in:
j 2013-06-01 12:25:20 +02:00
parent 96f7975747
commit 7d7c7c9407

View file

@ -15,7 +15,7 @@ def find(query, timeout=ox.cache.cache_timeout):
url = 'http://duckduckgo.com/html/?' + params url = 'http://duckduckgo.com/html/?' + params
data = read_url(url, timeout=timeout, unicode=True) data = read_url(url, timeout=timeout, unicode=True)
results = [] results = []
regex = '<a .*?class="l le" href="(.+?)">(.*?)</a>.*?<div class="cra">(.*?)</div>' regex = '<a .*?class="large" href="(.+?)">(.*?)</a>.*?<div class="snippet">(.*?)</div>'
for r in re.compile(regex, re.DOTALL).findall(data): for r in re.compile(regex, re.DOTALL).findall(data):
results.append((strip_tags(decode_html(r[1])), r[0], strip_tags(decode_html(r[2])))) results.append((strip_tags(decode_html(r[1])), r[0], strip_tags(decode_html(r[2]))))
return results return results