mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add WH Smith. Improve ebookshoppe_uk
This commit is contained in:
parent
93128ab03f
commit
b244246fce
@ -1143,6 +1143,7 @@ class StoreArchiveOrgStore(StoreBase):
|
|||||||
drm_free_only = True
|
drm_free_only = True
|
||||||
headquarters = 'US'
|
headquarters = 'US'
|
||||||
formats = ['DAISY', 'DJVU', 'EPUB', 'MOBI', 'PDF', 'TXT']
|
formats = ['DAISY', 'DJVU', 'EPUB', 'MOBI', 'PDF', 'TXT']
|
||||||
|
affiliate = False
|
||||||
|
|
||||||
class StoreBaenWebScriptionStore(StoreBase):
|
class StoreBaenWebScriptionStore(StoreBase):
|
||||||
name = 'Baen WebScription'
|
name = 'Baen WebScription'
|
||||||
@ -1152,6 +1153,7 @@ class StoreBaenWebScriptionStore(StoreBase):
|
|||||||
drm_free_only = True
|
drm_free_only = True
|
||||||
headquarters = 'US'
|
headquarters = 'US'
|
||||||
formats = ['EPUB', 'LIT', 'LRF', 'MOBI', 'RB', 'RTF', 'ZIP']
|
formats = ['EPUB', 'LIT', 'LRF', 'MOBI', 'RB', 'RTF', 'ZIP']
|
||||||
|
affiliate = False
|
||||||
|
|
||||||
class StoreBNStore(StoreBase):
|
class StoreBNStore(StoreBase):
|
||||||
name = 'Barnes and Noble'
|
name = 'Barnes and Noble'
|
||||||
@ -1161,6 +1163,7 @@ class StoreBNStore(StoreBase):
|
|||||||
drm_free_only = False
|
drm_free_only = False
|
||||||
headquarters = 'US'
|
headquarters = 'US'
|
||||||
formats = ['NOOK']
|
formats = ['NOOK']
|
||||||
|
affiliate = True
|
||||||
|
|
||||||
class StoreBeamEBooksDEStore(StoreBase):
|
class StoreBeamEBooksDEStore(StoreBase):
|
||||||
name = 'Beam EBooks DE'
|
name = 'Beam EBooks DE'
|
||||||
@ -1181,6 +1184,7 @@ class StoreBeWriteStore(StoreBase):
|
|||||||
drm_free_only = True
|
drm_free_only = True
|
||||||
headquarters = 'US'
|
headquarters = 'US'
|
||||||
formats = ['EPUB', 'MOBI', 'PDF']
|
formats = ['EPUB', 'MOBI', 'PDF']
|
||||||
|
affiliate = False
|
||||||
|
|
||||||
class StoreDieselEbooksStore(StoreBase):
|
class StoreDieselEbooksStore(StoreBase):
|
||||||
name = 'Diesel eBooks'
|
name = 'Diesel eBooks'
|
||||||
@ -1190,6 +1194,7 @@ class StoreDieselEbooksStore(StoreBase):
|
|||||||
drm_free_only = False
|
drm_free_only = False
|
||||||
headquarters = 'US'
|
headquarters = 'US'
|
||||||
formats = ['EPUB', 'PDF']
|
formats = ['EPUB', 'PDF']
|
||||||
|
affiliate = True
|
||||||
|
|
||||||
class StoreEbookscomStore(StoreBase):
|
class StoreEbookscomStore(StoreBase):
|
||||||
name = 'eBooks.com'
|
name = 'eBooks.com'
|
||||||
@ -1199,6 +1204,18 @@ class StoreEbookscomStore(StoreBase):
|
|||||||
drm_free_only = False
|
drm_free_only = False
|
||||||
headquarters = 'US'
|
headquarters = 'US'
|
||||||
formats = ['EPUB', 'LIT', 'MOBI', 'PDF']
|
formats = ['EPUB', 'LIT', 'MOBI', 'PDF']
|
||||||
|
affiliate = True
|
||||||
|
|
||||||
|
class StoreEPubBuyDEStore(StoreBase):
|
||||||
|
name = 'EPUBBuy DE'
|
||||||
|
author = 'Charles Haley'
|
||||||
|
description = u'Bei EPUBBuy.com finden Sie ausschliesslich eBooks im weitverbreiteten EPUB-Format und ohne DRM. So haben Sie die freie Wahl, wo Sie Ihr eBook lesen: Tablet, eBook-Reader, Smartphone oder einfach auf Ihrem PC. So macht eBook-Lesen Spaß!'
|
||||||
|
actual_plugin = 'calibre.gui2.store.epubbuy_de_plugin:EPubBuyDEStore'
|
||||||
|
|
||||||
|
drm_free_only = True
|
||||||
|
headquarters = 'DE'
|
||||||
|
formats = ['EPUB']
|
||||||
|
affiliate = True
|
||||||
|
|
||||||
class StoreEBookShoppeUKStore(StoreBase):
|
class StoreEBookShoppeUKStore(StoreBase):
|
||||||
name = 'ebookShoppe UK'
|
name = 'ebookShoppe UK'
|
||||||
@ -1211,16 +1228,6 @@ class StoreEBookShoppeUKStore(StoreBase):
|
|||||||
formats = ['EPUB', 'PDF']
|
formats = ['EPUB', 'PDF']
|
||||||
affiliate = True
|
affiliate = True
|
||||||
|
|
||||||
class StoreEPubBuyDEStore(StoreBase):
|
|
||||||
name = 'EPUBBuy DE'
|
|
||||||
author = 'Charles Haley'
|
|
||||||
description = u'Bei EPUBBuy.com finden Sie ausschliesslich eBooks im weitverbreiteten EPUB-Format und ohne DRM. So haben Sie die freie Wahl, wo Sie Ihr eBook lesen: Tablet, eBook-Reader, Smartphone oder einfach auf Ihrem PC. So macht eBook-Lesen Spaß!'
|
|
||||||
actual_plugin = 'calibre.gui2.store.epubbuy_de_plugin:EPubBuyDEStore'
|
|
||||||
|
|
||||||
drm_free_only = True
|
|
||||||
headquarters = 'DE'
|
|
||||||
formats = ['EPUB']
|
|
||||||
|
|
||||||
class StoreEHarlequinStore(StoreBase):
|
class StoreEHarlequinStore(StoreBase):
|
||||||
name = 'eHarlequin'
|
name = 'eHarlequin'
|
||||||
description = u'A global leader in series romance and one of the world\'s leading publishers of books for women. Offers women a broad range of reading from romance to bestseller fiction, from young adult novels to erotic literature, from nonfiction to fantasy, from African-American novels to inspirational romance, and more.'
|
description = u'A global leader in series romance and one of the world\'s leading publishers of books for women. Offers women a broad range of reading from romance to bestseller fiction, from young adult novels to erotic literature, from nonfiction to fantasy, from African-American novels to inspirational romance, and more.'
|
||||||
@ -1229,6 +1236,7 @@ class StoreEHarlequinStore(StoreBase):
|
|||||||
drm_free_only = False
|
drm_free_only = False
|
||||||
headquarters = 'CA'
|
headquarters = 'CA'
|
||||||
formats = ['EPUB', 'PDF']
|
formats = ['EPUB', 'PDF']
|
||||||
|
affiliate = True
|
||||||
|
|
||||||
class StoreFeedbooksStore(StoreBase):
|
class StoreFeedbooksStore(StoreBase):
|
||||||
name = 'Feedbooks'
|
name = 'Feedbooks'
|
||||||
@ -1238,6 +1246,7 @@ class StoreFeedbooksStore(StoreBase):
|
|||||||
drm_free_only = False
|
drm_free_only = False
|
||||||
headquarters = 'FR'
|
headquarters = 'FR'
|
||||||
formats = ['EPUB', 'MOBI', 'PDF']
|
formats = ['EPUB', 'MOBI', 'PDF']
|
||||||
|
affiliate = False
|
||||||
|
|
||||||
class StoreFoylesUKStore(StoreBase):
|
class StoreFoylesUKStore(StoreBase):
|
||||||
name = 'Foyles UK'
|
name = 'Foyles UK'
|
||||||
@ -1259,6 +1268,7 @@ class StoreGandalfStore(StoreBase):
|
|||||||
drm_free_only = False
|
drm_free_only = False
|
||||||
headquarters = 'PL'
|
headquarters = 'PL'
|
||||||
formats = ['EPUB', 'PDF']
|
formats = ['EPUB', 'PDF']
|
||||||
|
affiliate = False
|
||||||
|
|
||||||
class StoreGoogleBooksStore(StoreBase):
|
class StoreGoogleBooksStore(StoreBase):
|
||||||
name = 'Google Books'
|
name = 'Google Books'
|
||||||
@ -1268,6 +1278,7 @@ class StoreGoogleBooksStore(StoreBase):
|
|||||||
drm_free_only = False
|
drm_free_only = False
|
||||||
headquarters = 'US'
|
headquarters = 'US'
|
||||||
formats = ['EPUB', 'PDF', 'TXT']
|
formats = ['EPUB', 'PDF', 'TXT']
|
||||||
|
affiliate = False
|
||||||
|
|
||||||
class StoreGutenbergStore(StoreBase):
|
class StoreGutenbergStore(StoreBase):
|
||||||
name = 'Project Gutenberg'
|
name = 'Project Gutenberg'
|
||||||
@ -1277,6 +1288,7 @@ class StoreGutenbergStore(StoreBase):
|
|||||||
drm_free_only = True
|
drm_free_only = True
|
||||||
headquarters = 'US'
|
headquarters = 'US'
|
||||||
formats = ['EPUB', 'HTML', 'MOBI', 'PDB', 'TXT']
|
formats = ['EPUB', 'HTML', 'MOBI', 'PDB', 'TXT']
|
||||||
|
affiliate = False
|
||||||
|
|
||||||
class StoreKoboStore(StoreBase):
|
class StoreKoboStore(StoreBase):
|
||||||
name = 'Kobo'
|
name = 'Kobo'
|
||||||
@ -1286,6 +1298,7 @@ class StoreKoboStore(StoreBase):
|
|||||||
drm_free_only = False
|
drm_free_only = False
|
||||||
headquarters = 'CA'
|
headquarters = 'CA'
|
||||||
formats = ['EPUB']
|
formats = ['EPUB']
|
||||||
|
affiliate = True
|
||||||
|
|
||||||
class StoreLegimiStore(StoreBase):
|
class StoreLegimiStore(StoreBase):
|
||||||
name = 'Legimi'
|
name = 'Legimi'
|
||||||
@ -1296,6 +1309,7 @@ class StoreLegimiStore(StoreBase):
|
|||||||
drm_free_only = False
|
drm_free_only = False
|
||||||
headquarters = 'PL'
|
headquarters = 'PL'
|
||||||
formats = ['EPUB']
|
formats = ['EPUB']
|
||||||
|
affiliate = False
|
||||||
|
|
||||||
class StoreManyBooksStore(StoreBase):
|
class StoreManyBooksStore(StoreBase):
|
||||||
name = 'ManyBooks'
|
name = 'ManyBooks'
|
||||||
@ -1305,6 +1319,7 @@ class StoreManyBooksStore(StoreBase):
|
|||||||
drm_free_only = True
|
drm_free_only = True
|
||||||
headquarters = 'US'
|
headquarters = 'US'
|
||||||
formats = ['EPUB', 'FB2', 'JAR', 'LIT', 'LRF', 'MOBI', 'PDB', 'PDF', 'RB', 'RTF', 'TCR', 'TXT', 'ZIP']
|
formats = ['EPUB', 'FB2', 'JAR', 'LIT', 'LRF', 'MOBI', 'PDB', 'PDF', 'RB', 'RTF', 'TCR', 'TXT', 'ZIP']
|
||||||
|
affiliate = False
|
||||||
|
|
||||||
class StoreMobileReadStore(StoreBase):
|
class StoreMobileReadStore(StoreBase):
|
||||||
name = 'MobileRead'
|
name = 'MobileRead'
|
||||||
@ -1314,6 +1329,7 @@ class StoreMobileReadStore(StoreBase):
|
|||||||
drm_free_only = True
|
drm_free_only = True
|
||||||
headquarters = 'CH'
|
headquarters = 'CH'
|
||||||
formats = ['EPUB', 'IMP', 'LRF', 'LIT', 'MOBI', 'PDF']
|
formats = ['EPUB', 'IMP', 'LRF', 'LIT', 'MOBI', 'PDF']
|
||||||
|
affiliate = False
|
||||||
|
|
||||||
class StoreNextoStore(StoreBase):
|
class StoreNextoStore(StoreBase):
|
||||||
name = 'Nexto'
|
name = 'Nexto'
|
||||||
@ -1324,6 +1340,7 @@ class StoreNextoStore(StoreBase):
|
|||||||
drm_free_only = False
|
drm_free_only = False
|
||||||
headquarters = 'PL'
|
headquarters = 'PL'
|
||||||
formats = ['EPUB', 'PDF']
|
formats = ['EPUB', 'PDF']
|
||||||
|
affiliate = True
|
||||||
|
|
||||||
class StoreOpenLibraryStore(StoreBase):
|
class StoreOpenLibraryStore(StoreBase):
|
||||||
name = 'Open Library'
|
name = 'Open Library'
|
||||||
@ -1333,6 +1350,7 @@ class StoreOpenLibraryStore(StoreBase):
|
|||||||
drm_free_only = True
|
drm_free_only = True
|
||||||
headquarters = 'US'
|
headquarters = 'US'
|
||||||
formats = ['DAISY', 'DJVU', 'EPUB', 'MOBI', 'PDF', 'TXT']
|
formats = ['DAISY', 'DJVU', 'EPUB', 'MOBI', 'PDF', 'TXT']
|
||||||
|
affiliate = False
|
||||||
|
|
||||||
class StoreOReillyStore(StoreBase):
|
class StoreOReillyStore(StoreBase):
|
||||||
name = 'OReilly'
|
name = 'OReilly'
|
||||||
@ -1342,6 +1360,7 @@ class StoreOReillyStore(StoreBase):
|
|||||||
drm_free_only = True
|
drm_free_only = True
|
||||||
headquarters = 'US'
|
headquarters = 'US'
|
||||||
formats = ['APK', 'DAISY', 'EPUB', 'MOBI', 'PDF']
|
formats = ['APK', 'DAISY', 'EPUB', 'MOBI', 'PDF']
|
||||||
|
affiliate = False
|
||||||
|
|
||||||
class StorePragmaticBookshelfStore(StoreBase):
|
class StorePragmaticBookshelfStore(StoreBase):
|
||||||
name = 'Pragmatic Bookshelf'
|
name = 'Pragmatic Bookshelf'
|
||||||
@ -1351,6 +1370,7 @@ class StorePragmaticBookshelfStore(StoreBase):
|
|||||||
drm_free_only = True
|
drm_free_only = True
|
||||||
headquarters = 'US'
|
headquarters = 'US'
|
||||||
formats = ['EPUB', 'MOBI', 'PDF']
|
formats = ['EPUB', 'MOBI', 'PDF']
|
||||||
|
affiliate = False
|
||||||
|
|
||||||
class StoreSmashwordsStore(StoreBase):
|
class StoreSmashwordsStore(StoreBase):
|
||||||
name = 'Smashwords'
|
name = 'Smashwords'
|
||||||
@ -1360,6 +1380,7 @@ class StoreSmashwordsStore(StoreBase):
|
|||||||
drm_free_only = True
|
drm_free_only = True
|
||||||
headquarters = 'US'
|
headquarters = 'US'
|
||||||
formats = ['EPUB', 'HTML', 'LRF', 'MOBI', 'PDB', 'RTF', 'TXT']
|
formats = ['EPUB', 'HTML', 'LRF', 'MOBI', 'PDB', 'RTF', 'TXT']
|
||||||
|
affiliate = True
|
||||||
|
|
||||||
class StoreVirtualoStore(StoreBase):
|
class StoreVirtualoStore(StoreBase):
|
||||||
name = 'Virtualo'
|
name = 'Virtualo'
|
||||||
@ -1370,6 +1391,7 @@ class StoreVirtualoStore(StoreBase):
|
|||||||
drm_free_only = False
|
drm_free_only = False
|
||||||
headquarters = 'PL'
|
headquarters = 'PL'
|
||||||
formats = ['EPUB', 'PDF']
|
formats = ['EPUB', 'PDF']
|
||||||
|
affiliate = False
|
||||||
|
|
||||||
class StoreWaterstonesUKStore(StoreBase):
|
class StoreWaterstonesUKStore(StoreBase):
|
||||||
name = 'Waterstones UK'
|
name = 'Waterstones UK'
|
||||||
@ -1380,6 +1402,7 @@ class StoreWaterstonesUKStore(StoreBase):
|
|||||||
drm_free_only = False
|
drm_free_only = False
|
||||||
headquarters = 'UK'
|
headquarters = 'UK'
|
||||||
formats = ['EPUB', 'PDF']
|
formats = ['EPUB', 'PDF']
|
||||||
|
affiliate = False
|
||||||
|
|
||||||
class StoreWeightlessBooksStore(StoreBase):
|
class StoreWeightlessBooksStore(StoreBase):
|
||||||
name = 'Weightless Books'
|
name = 'Weightless Books'
|
||||||
@ -1389,6 +1412,18 @@ class StoreWeightlessBooksStore(StoreBase):
|
|||||||
drm_free_only = True
|
drm_free_only = True
|
||||||
headquarters = 'US'
|
headquarters = 'US'
|
||||||
formats = ['EPUB', 'HTML', 'LIT', 'MOBI', 'PDF']
|
formats = ['EPUB', 'HTML', 'LIT', 'MOBI', 'PDF']
|
||||||
|
affiliate = False
|
||||||
|
|
||||||
|
class StoreWHSmithUKStore(StoreBase):
|
||||||
|
name = 'WH Smith UK'
|
||||||
|
author = 'Charles Haley'
|
||||||
|
description = u"With over 550 stores on the high street and 490 stores at airports, train stations, hospitals and motorway services, WHSmith is one of the UK's leading retail groups and a household name."
|
||||||
|
actual_plugin = 'calibre.gui2.store.whsmith_uk_plugin:WHSmithUKStore'
|
||||||
|
|
||||||
|
drm_free_only = False
|
||||||
|
headquarters = 'UK'
|
||||||
|
formats = ['EPUB', 'PDF']
|
||||||
|
affiliate = False
|
||||||
|
|
||||||
class StoreWizardsTowerBooksStore(StoreBase):
|
class StoreWizardsTowerBooksStore(StoreBase):
|
||||||
name = 'Wizards Tower Books'
|
name = 'Wizards Tower Books'
|
||||||
@ -1398,6 +1433,7 @@ class StoreWizardsTowerBooksStore(StoreBase):
|
|||||||
drm_free_only = True
|
drm_free_only = True
|
||||||
headquarters = 'UK'
|
headquarters = 'UK'
|
||||||
formats = ['EPUB', 'MOBI']
|
formats = ['EPUB', 'MOBI']
|
||||||
|
affiliate = False
|
||||||
|
|
||||||
class StoreWoblinkStore(StoreBase):
|
class StoreWoblinkStore(StoreBase):
|
||||||
name = 'Woblink'
|
name = 'Woblink'
|
||||||
@ -1408,6 +1444,7 @@ class StoreWoblinkStore(StoreBase):
|
|||||||
drm_free_only = False
|
drm_free_only = False
|
||||||
headquarters = 'PL'
|
headquarters = 'PL'
|
||||||
formats = ['EPUB']
|
formats = ['EPUB']
|
||||||
|
affiliate = False
|
||||||
|
|
||||||
plugins += [
|
plugins += [
|
||||||
StoreArchiveOrgStore,
|
StoreArchiveOrgStore,
|
||||||
@ -1420,7 +1457,7 @@ plugins += [
|
|||||||
StoreBeWriteStore,
|
StoreBeWriteStore,
|
||||||
StoreDieselEbooksStore,
|
StoreDieselEbooksStore,
|
||||||
StoreEbookscomStore,
|
StoreEbookscomStore,
|
||||||
#StoreEBookShoppeUKStore,
|
StoreEBookShoppeUKStore,
|
||||||
StoreEPubBuyDEStore,
|
StoreEPubBuyDEStore,
|
||||||
StoreEHarlequinStore,
|
StoreEHarlequinStore,
|
||||||
StoreFeedbooksStore,
|
StoreFeedbooksStore,
|
||||||
@ -1440,6 +1477,7 @@ plugins += [
|
|||||||
StoreVirtualoStore,
|
StoreVirtualoStore,
|
||||||
StoreWaterstonesUKStore,
|
StoreWaterstonesUKStore,
|
||||||
StoreWeightlessBooksStore,
|
StoreWeightlessBooksStore,
|
||||||
|
StoreWHSmithUKStore,
|
||||||
StoreWizardsTowerBooksStore,
|
StoreWizardsTowerBooksStore,
|
||||||
StoreWoblinkStore
|
StoreWoblinkStore
|
||||||
]
|
]
|
||||||
|
@ -62,18 +62,14 @@ class EBookShoppeUKStore(BasicStoreConfig, StorePlugin):
|
|||||||
s = SearchResult()
|
s = SearchResult()
|
||||||
s.cover_url = cover_url
|
s.cover_url = cover_url
|
||||||
s.title = title.strip()
|
s.title = title.strip()
|
||||||
# Set the author to the query terms to ensure that author
|
|
||||||
# queries match something when pruning searches. Of course, this
|
|
||||||
# means that all books will match. Sigh...
|
|
||||||
s.author = query
|
|
||||||
s.price = price
|
s.price = price
|
||||||
s.drm = SearchResult.DRM_UNLOCKED
|
s.drm = SearchResult.DRM_UNLOCKED
|
||||||
s.detail_item = id
|
s.detail_item = id
|
||||||
s.formats = ''
|
self.get_author_and_formats(s, timeout)
|
||||||
|
|
||||||
yield s
|
yield s
|
||||||
|
|
||||||
def get_details(self, search_result, timeout):
|
def get_author_and_formats(self, search_result, timeout):
|
||||||
br = browser()
|
br = browser()
|
||||||
with closing(br.open(search_result.detail_item, timeout=timeout)) as nf:
|
with closing(br.open(search_result.detail_item, timeout=timeout)) as nf:
|
||||||
idata = html.fromstring(nf.read())
|
idata = html.fromstring(nf.read())
|
||||||
|
83
src/calibre/gui2/store/whsmith_uk_plugin.py
Normal file
83
src/calibre/gui2/store/whsmith_uk_plugin.py
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
__license__ = 'GPL 3'
|
||||||
|
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
||||||
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
import urllib2
|
||||||
|
from contextlib import closing
|
||||||
|
|
||||||
|
from lxml import html
|
||||||
|
|
||||||
|
from PyQt4.Qt import QUrl
|
||||||
|
|
||||||
|
from calibre import browser
|
||||||
|
from calibre.gui2 import open_url
|
||||||
|
from calibre.gui2.store import StorePlugin
|
||||||
|
from calibre.gui2.store.basic_config import BasicStoreConfig
|
||||||
|
from calibre.gui2.store.search_result import SearchResult
|
||||||
|
from calibre.gui2.store.web_store_dialog import WebStoreDialog
|
||||||
|
|
||||||
|
class WHSmithUKStore(BasicStoreConfig, StorePlugin):
|
||||||
|
|
||||||
|
def open(self, parent=None, detail_item=None, external=False):
|
||||||
|
url = 'http://www.whsmith.co.uk/'
|
||||||
|
url_details = ''
|
||||||
|
|
||||||
|
if external or self.config.get('open_external', False):
|
||||||
|
if detail_item:
|
||||||
|
url = url_details + detail_item
|
||||||
|
open_url(QUrl(url))
|
||||||
|
else:
|
||||||
|
detail_url = None
|
||||||
|
if detail_item:
|
||||||
|
detail_url = url_details + detail_item
|
||||||
|
d = WebStoreDialog(self.gui, url, parent, detail_url)
|
||||||
|
d.setWindowTitle(self.name)
|
||||||
|
d.set_tags(self.config.get('tags', ''))
|
||||||
|
d.exec_()
|
||||||
|
|
||||||
|
def search(self, query, max_results=10, timeout=60):
|
||||||
|
url = ('http://www.whsmith.co.uk/CatalogAndSearch/SearchWithinCategory.aspx'
|
||||||
|
'?cat=\Books\eb_eBooks&gq=' + urllib2.quote(query))
|
||||||
|
|
||||||
|
br = browser()
|
||||||
|
|
||||||
|
counter = max_results
|
||||||
|
with closing(br.open(url, timeout=timeout)) as f:
|
||||||
|
doc = html.fromstring(f.read())
|
||||||
|
for data in doc.xpath('//div[@class="product-search"]/'
|
||||||
|
'div[contains(@id, "whsSearchResultItem")]'):
|
||||||
|
if counter <= 0:
|
||||||
|
break
|
||||||
|
|
||||||
|
id = ''.join(data.xpath('.//a[contains(@id, "labelProductTitle")]/@href'))
|
||||||
|
if not id:
|
||||||
|
continue
|
||||||
|
cover_url = ''.join(data.xpath('.//a[contains(@id, "hlinkProductImage")]/img/@src'))
|
||||||
|
title = ''.join(data.xpath('.//a[contains(@id, "labelProductTitle")]/text()'))
|
||||||
|
author = ', '.join(data.xpath('.//div[@class="author"]/h3/span/text()'))
|
||||||
|
price = ''.join(data.xpath('.//span[contains(@id, "labelProductPrice")]/text()'))
|
||||||
|
pdf = data.xpath('boolean(.//span[contains(@id, "labelFormatText") and '
|
||||||
|
'contains(., "PDF")])')
|
||||||
|
epub = data.xpath('boolean(.//span[contains(@id, "labelFormatText") and '
|
||||||
|
'contains(., "ePub")])')
|
||||||
|
counter -= 1
|
||||||
|
|
||||||
|
s = SearchResult()
|
||||||
|
s.cover_url = cover_url
|
||||||
|
s.title = title.strip()
|
||||||
|
s.author = author.strip()
|
||||||
|
s.price = price
|
||||||
|
s.drm = SearchResult.DRM_LOCKED
|
||||||
|
s.detail_item = id
|
||||||
|
formats = []
|
||||||
|
if epub:
|
||||||
|
formats.append('ePub')
|
||||||
|
if pdf:
|
||||||
|
formats.append('PDF')
|
||||||
|
s.formats = ', '.join(formats)
|
||||||
|
|
||||||
|
yield s
|
Loading…
x
Reference in New Issue
Block a user