|
|
@ -16,11 +16,13 @@ class CheeseCom(object):
|
|
|
|
def query(self, q):
|
|
|
|
def query(self, q):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
r = requests.get(BASE_URL, params=dict(q=q))
|
|
|
|
r = requests.get(BASE_URL, params=dict(q=q))
|
|
|
|
|
|
|
|
d = pq(r.content)
|
|
|
|
if not r.history:
|
|
|
|
if not r.history:
|
|
|
|
raise CheeseComError('no exact match')
|
|
|
|
url = d('div[class~="cheese-item"]').eq(0).find('a').eq(0).attr('href')
|
|
|
|
|
|
|
|
r = requests.get(BASE_URL + url)
|
|
|
|
d = pq(r.content)
|
|
|
|
d = pq(r.content)
|
|
|
|
summary = []
|
|
|
|
summary = []
|
|
|
|
for p in d('ul[class="summary-points"]').find('p').items():
|
|
|
|
for p in d('ul[class~="summary-points"]').find('p').items():
|
|
|
|
summary.append(html.unescape(p.html(method='text')))
|
|
|
|
summary.append(html.unescape(p.html(method='text')))
|
|
|
|
return dict(
|
|
|
|
return dict(
|
|
|
|
url=d('meta[name="twitter:url"]').attr('content'),
|
|
|
|
url=d('meta[name="twitter:url"]').attr('content'),
|
|
|
|