mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
load more than 10 results in gandalf
This commit is contained in:
parent
d974ec57f6
commit
135d61b008
@ -3,7 +3,7 @@
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
__license__ = 'GPL 3'
|
||||
__copyright__ = '2011, Tomasz Długosz <tomek3d@gmail.com>'
|
||||
__copyright__ = '2011-2012, Tomasz Długosz <tomek3d@gmail.com>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import re
|
||||
@ -35,16 +35,14 @@ class GandalfStore(BasicStoreConfig, StorePlugin):
|
||||
d.exec_()
|
||||
|
||||
def search(self, query, max_results=10, timeout=60):
|
||||
url = 'http://www.gandalf.com.pl/s/'
|
||||
values={
|
||||
'search': query.decode('utf-8').encode('iso8859_2'),
|
||||
'dzialx':'11'
|
||||
}
|
||||
counter = max_results
|
||||
page = 1
|
||||
url = 'http://www.gandalf.com.pl/we/' + urllib.quote_plus(query.decode('utf-8').encode('iso8859_2')) + '/bdb'
|
||||
|
||||
br = browser()
|
||||
|
||||
counter = max_results
|
||||
with closing(br.open(url, data=urllib.urlencode(values), timeout=timeout)) as f:
|
||||
while counter:
|
||||
with closing(br.open((url + str(page-1) + '/#s') if (page-1) else (url + '/#s'), timeout=timeout)) as f:
|
||||
doc = html.fromstring(f.read())
|
||||
for data in doc.xpath('//div[@class="box"]'):
|
||||
if counter <= 0:
|
||||
@ -79,3 +77,6 @@ class GandalfStore(BasicStoreConfig, StorePlugin):
|
||||
s.formats = formats.upper().strip()
|
||||
|
||||
yield s
|
||||
if not doc.xpath('boolean(//div[@class="wyszukiwanie_podstawowe_header"]//div[@class="box"])'):
|
||||
break
|
||||
page+=1
|
||||
|
Loading…
x
Reference in New Issue
Block a user