From 4ca4751bfc3d6efd637aa342b6daeefafe167cd9 Mon Sep 17 00:00:00 2001 From: tomMulholland Date: Tue, 22 Apr 2014 20:36:49 -0500 Subject: [PATCH 1/2] Update search.py modified the functions _extract_results and _extract_description according to these suggestions: http://www.catonmat.net/c/27124 --- xgoogle/search.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xgoogle/search.py b/xgoogle/search.py index 98b681e..85d0460 100755 --- a/xgoogle/search.py +++ b/xgoogle/search.py @@ -322,7 +322,8 @@ def _extract_info(self, soup): return {'from': int(matches.group(1)), 'to': int(matches.group(2)), 'total': int(matches.group(3))} def _extract_results(self, soup): - results = soup.findAll('p', {'class': 'g'}) + #results = soup.findAll('p', {'class': 'g'}) + results = soup.findAll('li','g') ret_res = [] for result in results: eres = self._extract_result(result) @@ -352,7 +353,8 @@ def _extract_title_url(self, result): return title, url def _extract_description(self, result): - desc_td = result.findNext('td') + #desc_td = result.findNext('td') + desc_div = result.find('span', 'st')) if not desc_td: self._maybe_raise(ParseError, "Description tag in Google search result was not found", result) return None From 0db69c674626f7a2b1702a7ae1179e1b8471389b Mon Sep 17 00:00:00 2001 From: Justin Vieira Date: Fri, 17 Jul 2015 13:55:57 -0400 Subject: [PATCH 2/2] fix extra '(' in master --- xgoogle/search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xgoogle/search.py b/xgoogle/search.py index 85d0460..d5306fc 100755 --- a/xgoogle/search.py +++ b/xgoogle/search.py @@ -354,7 +354,7 @@ def _extract_title_url(self, result): def _extract_description(self, result): #desc_td = result.findNext('td') - desc_div = result.find('span', 'st')) + desc_div = result.find('span', 'st') if not desc_td: self._maybe_raise(ParseError, "Description tag in Google search result was not found", result) return None