diff --git a/services/cheesecom.py b/services/cheesecom.py index d1c2b4f..12354a3 100644 --- a/services/cheesecom.py +++ b/services/cheesecom.py @@ -16,11 +16,13 @@ class CheeseCom(object): def query(self, q): try: r = requests.get(BASE_URL, params=dict(q=q)) - if not r.history: - raise CheeseComError('no exact match') d = pq(r.content) + if not r.history: + url = d('div[class~="cheese-item"]').eq(0).find('a').eq(0).attr('href') + r = requests.get(BASE_URL + url) + d = pq(r.content) 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'))) return dict( url=d('meta[name="twitter:url"]').attr('content'),