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

Proposed by Stefano Rivera
Status: Merged
Approved by: Stefano Rivera
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 Approve
Review via email: mp+81752@code.launchpad.net

Commit message

Update gcalc scraping

To post a comment you must log in.
Revision history for this message
Jonathan Hitchcock (vhata) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ibid/plugins/google.py'
--- ibid/plugins/google.py 2011-02-16 08:01:51 +0000
+++ ibid/plugins/google.py 2011-11-09 16:06:28 +0000
@@ -108,7 +108,7 @@
108 def calc(self, event, expression):108 def calc(self, event, expression):
109 tree = self._google_scrape_search(expression)109 tree = self._google_scrape_search(expression)
110110
111 nodes = [node for node in tree.findall('.//h2/b')]111 nodes = [node for node in tree.findall('.//h2') if node.get('class') == 'r']
112 if len(nodes) == 1:112 if len(nodes) == 1:
113 # ElementTree doesn't support inline tags:113 # ElementTree doesn't support inline tags:
114 # May return ASCII unless an encoding is specified.114 # May return ASCII unless an encoding is specified.
@@ -121,6 +121,7 @@
121 node = re.sub(r'(\d)\s+(\d)', lambda x: x.group(1) + x.group(2),121 node = re.sub(r'(\d)\s+(\d)', lambda x: x.group(1) + x.group(2),
122 node)122 node)
123 node = decode_htmlentities(node)123 node = decode_htmlentities(node)
124 node = re.sub(r'\s+', ' ', node)
124 event.addresponse(node)125 event.addresponse(node)
125 else:126 else:
126 event.addresponse(127 event.addresponse(

Subscribers

People subscribed via source and target branches

to all changes: