From b20dbb3c06b3467098a69876c5a5675847756177 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 28 Dec 2014 10:46:13 +0530 Subject: [PATCH] ... --- src/calibre/gui2/store/stores/gutenberg_plugin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/store/stores/gutenberg_plugin.py b/src/calibre/gui2/store/stores/gutenberg_plugin.py index c281ba9237..e4c3c6cd78 100644 --- a/src/calibre/gui2/store/stores/gutenberg_plugin.py +++ b/src/calibre/gui2/store/stores/gutenberg_plugin.py @@ -28,13 +28,17 @@ def fix_url(url): url = 'http:' + url return url -def search(query, max_results=10, timeout=60): +def search(query, max_results=10, timeout=60, write_raw_to=None): url = 'http://m.gutenberg.org/ebooks/search.opds/?query=' + urllib.quote_plus(query) counter = max_results br = browser(user_agent='calibre/'+__version__) with closing(br.open(url, timeout=timeout)) as f: - doc = etree.fromstring(f.read()) + raw = f.read() + if write_raw_to is not None: + with open(write_raw_to, 'wb') as f: + f.write(raw) + doc = etree.fromstring(raw) for data in doc.xpath('//*[local-name() = "entry"]'): if counter <= 0: break