net/cache readUrl->read_url / Unicode -> unicode=True
format replace all CammelCase with under_score
This commit is contained in:
parent
c1d0fc6242
commit
2de989e188
33 changed files with 243 additions and 254 deletions
|
|
@ -3,9 +3,9 @@
|
|||
import re
|
||||
import urllib
|
||||
import ox
|
||||
from ox import stripTags, decodeHtml
|
||||
from ox import strip_tags, decodeHtml
|
||||
from ox.utils import json
|
||||
from ox.cache import readUrlUnicode
|
||||
from ox.cache import read_url
|
||||
|
||||
|
||||
def find(query, timeout=ox.cache.cache_timeout):
|
||||
|
|
@ -13,10 +13,10 @@ def find(query, timeout=ox.cache.cache_timeout):
|
|||
query = query.encode('utf-8')
|
||||
params = urllib.urlencode({'q': query})
|
||||
url = 'http://duckduckgo.com/html/?' + params
|
||||
data = readUrlUnicode(url, timeout=timeout)
|
||||
data = read_url(url, timeout=timeout, unicode=True)
|
||||
results = []
|
||||
regex = '<a .*?class="l le" href="(.+?)">(.*?)</a>.*?<div class="cra">(.*?)</div>'
|
||||
for r in re.compile(regex, re.DOTALL).findall(data):
|
||||
results.append((stripTags(decodeHtml(r[1])), r[0], stripTags(decodeHtml(r[2]))))
|
||||
results.append((strip_tags(decodeHtml(r[1])), r[0], strip_tags(decodeHtml(r[2]))))
|
||||
return results
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue