From 83895be2f813b39d0c09fe56aabb6313936edef9 Mon Sep 17 00:00:00 2001 From: John Schember Date: Sun, 5 Jun 2011 19:43:22 -0400 Subject: [PATCH] Store: Fix B&N store to work with new B&N website layout. --- src/calibre/gui2/store/bn_plugin.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/calibre/gui2/store/bn_plugin.py b/src/calibre/gui2/store/bn_plugin.py index 62826e825d..eec8e1690d 100644 --- a/src/calibre/gui2/store/bn_plugin.py +++ b/src/calibre/gui2/store/bn_plugin.py @@ -47,26 +47,26 @@ class BNStore(BasicStoreConfig, StorePlugin): d.exec_() def search(self, query, max_results=10, timeout=60): - url = 'http://productsearch.barnesandnoble.com/search/results.aspx?STORE=EBOOK&SZE=%s&WRD=' % max_results - url += urllib.quote_plus(query) + query = query.replace(' ', '-') + url = 'http://www.barnesandnoble.com/s/%s?store=ebook&sze=%s' % (query, max_results) br = browser() counter = max_results with closing(br.open(url, timeout=timeout)) as f: doc = html.fromstring(f.read()) - for data in doc.xpath('//ul[contains(@class, "wgt-search-results-display")]/li[contains(@class, "search-result-item") and contains(@class, "nook-result-item")]'): + for data in doc.xpath('//ul[contains(@class, "result-set")]/li[contains(@class, "result")]'): if counter <= 0: break - id = ''.join(data.xpath('.//div[contains(@class, "wgt-product-image-module")]/a/@href')) + id = ''.join(data.xpath('.//div[contains(@class, "image")]/a/@href')) if not id: continue - cover_url = ''.join(data.xpath('.//div[contains(@class, "wgt-product-image-module")]/a/img/@src')) + cover_url = ''.join(data.xpath('.//div[contains(@class, "image")]//img/@src')) - title = ''.join(data.xpath('.//span[@class="product-title"]/a/text()')) - author = ', '.join(data.xpath('.//span[@class="contributers-line"]/a/text()')) - price = ''.join(data.xpath('.//span[contains(@class, "onlinePriceValue2")]/text()')) + title = ''.join(data.xpath('.//p[@class="title"]//span[@class="name"]/text()')) + author = ', '.join(data.xpath('.//ul[@class="contributors"]//li[position()>1]//a/text()')) + price = ''.join(data.xpath('.//table[@class="displayed-formats"]//a[@class="subtle"]/text()')) counter -= 1 @@ -74,9 +74,9 @@ class BNStore(BasicStoreConfig, StorePlugin): s.cover_url = cover_url s.title = title.strip() s.author = author.strip() - s.price = price + s.price = price.strip() s.detail_item = id.strip() s.drm = SearchResult.DRM_UNKNOWN s.formats = 'Nook' - + yield s