Skip to content

Commit

Permalink
Updated search.py with patch for the 0 results bug (see http://www.ca…
Browse files Browse the repository at this point in the history
  • Loading branch information
azappella committed Sep 19, 2010
1 parent e49fc55 commit 4329890
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions xgoogle/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,24 @@ def _set_results_par_page(self, rpp):
self._results_per_page = rpp

results_per_page = property(_get_results_per_page, _set_results_par_page)


## Fix to make the results appear / 11.06.2010 -> http://www.catonmat.net/blog/python-library-for-google-search
def get_results(self):
""" Gets a page of results """
if self.eor:
return []

MAX_VALUE = 1000000
page = self._get_results_page()
search_info = self._extract_info(page)
#search_info = self._extract_info(page)
results = self._extract_results(page)
search_info = {'from': self.results_per_page*self._page,
'to': self.results_per_page*self._page + len(results),
'total': MAX_VALUE}
if not self.results_info:
self.results_info = search_info
if self.num_results == 0:
self.eor = True
return []
results = self._extract_results(page)
if not results:
self.eor = True
return []
Expand Down

6 comments on commit 4329890

@azappella
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original fix found on http://www.catonmat.net/c/3009 and simply added/commited to the latest search.py pulled from http://github.com/pkrumins/xgoogle. Nothing special about this, it simply fixes the issue where 0 results are displayed for any given query. This bug had also been reported here http://github.com/pkrumins/xgoogle/issues#issue/3

@pkrumins
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works, thank you! i just pushed the changes!

@azappella
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Glad it works. Thanks for sharing the library!

@tslmy
Copy link

@tslmy tslmy commented on 4329890 Apr 5, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know why, it still won't work on my PC. Is it because I am from China?

@pkrumins
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure.

@tslmy
Copy link

@tslmy tslmy commented on 4329890 Apr 10, 2011 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.