Merge lp:~stefanor/ibid/google-scrapers-888132 into lp:ibid

Proposed by Stefano Rivera on 2011-11-09
Status: Merged
Approved by: Stefano Rivera on 2011-11-10
Approved revision: 1039
Merged at revision: 1041
Proposed branch: lp:~stefanor/ibid/google-scrapers-888132
Merge into: lp:ibid
Diff against target: 20 lines (+2/-1)
1 file modified
ibid/plugins/google.py (+2/-1)
To merge this branch: bzr merge lp:~stefanor/ibid/google-scrapers-888132
Reviewer Review Type Date Requested Status
Jonathan Hitchcock 2011-11-09 Approve on 2011-11-10
Review via email: mp+81752@code.launchpad.net

Commit message

Update gcalc scraping

To post a comment you must log in.
Jonathan Hitchcock (vhata) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ibid/plugins/google.py'
2--- ibid/plugins/google.py 2011-02-16 08:01:51 +0000
3+++ ibid/plugins/google.py 2011-11-09 16:06:28 +0000
4@@ -108,7 +108,7 @@
5 def calc(self, event, expression):
6 tree = self._google_scrape_search(expression)
7
8- nodes = [node for node in tree.findall('.//h2/b')]
9+ nodes = [node for node in tree.findall('.//h2') if node.get('class') == 'r']
10 if len(nodes) == 1:
11 # ElementTree doesn't support inline tags:
12 # May return ASCII unless an encoding is specified.
13@@ -121,6 +121,7 @@
14 node = re.sub(r'(\d)\s+(\d)', lambda x: x.group(1) + x.group(2),
15 node)
16 node = decode_htmlentities(node)
17+ node = re.sub(r'\s+', ' ', node)
18 event.addresponse(node)
19 else:
20 event.addresponse(

Subscribers

People subscribed via source and target branches

to all changes: