mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Beam store, with working links
This commit is contained in:
parent
1b985a67b4
commit
6ebdda7aa5
@ -23,8 +23,8 @@ from calibre.gui2.store.web_store_dialog import WebStoreDialog
|
|||||||
class BeamEBooksDEStore(BasicStoreConfig, StorePlugin):
|
class BeamEBooksDEStore(BasicStoreConfig, StorePlugin):
|
||||||
|
|
||||||
def open(self, parent=None, detail_item=None, external=False):
|
def open(self, parent=None, detail_item=None, external=False):
|
||||||
url = 'http://www.affiliwelt.net/klick.php?log=no&prid=908&pid=2&bannerid=10072&url=http://www.beam-ebooks.de'
|
url = 'http://klick.affiliwelt.net/klick.php?bannerid=10072&pid=32307&prid=908'
|
||||||
url_details = 'http://www.affiliwelt.net/klick.php?log=no&prid=908&pid=2&bannerid=10072&url=http://www.beam-ebooks.de{0}'
|
url_details = 'http://klick.affiliwelt.net/klick.php?bannerid=10730&pid=32307&prid=908&prodid={0}'
|
||||||
|
|
||||||
if external or self.config.get('open_external', False):
|
if external or self.config.get('open_external', False):
|
||||||
if detail_item:
|
if detail_item:
|
||||||
@ -34,7 +34,6 @@ class BeamEBooksDEStore(BasicStoreConfig, StorePlugin):
|
|||||||
detail_url = None
|
detail_url = None
|
||||||
if detail_item:
|
if detail_item:
|
||||||
detail_url = url_details.format(detail_item)
|
detail_url = url_details.format(detail_item)
|
||||||
print(detail_url)
|
|
||||||
d = WebStoreDialog(self.gui, url, parent, detail_url)
|
d = WebStoreDialog(self.gui, url, parent, detail_url)
|
||||||
d.setWindowTitle(self.name)
|
d.setWindowTitle(self.name)
|
||||||
d.set_tags(self.config.get('tags', ''))
|
d.set_tags(self.config.get('tags', ''))
|
||||||
@ -42,33 +41,28 @@ class BeamEBooksDEStore(BasicStoreConfig, StorePlugin):
|
|||||||
|
|
||||||
def search(self, query, max_results=10, timeout=60):
|
def search(self, query, max_results=10, timeout=60):
|
||||||
url = 'http://www.beam-ebooks.de/suchergebnis.php?Type=&sw=' + urllib2.quote(query)
|
url = 'http://www.beam-ebooks.de/suchergebnis.php?Type=&sw=' + urllib2.quote(query)
|
||||||
print(url)
|
|
||||||
br = browser()
|
br = browser()
|
||||||
|
|
||||||
counter = max_results
|
counter = max_results
|
||||||
with closing(br.open(url, timeout=timeout)) as f:
|
with closing(br.open(url, timeout=timeout)) as f:
|
||||||
doc = html.fromstring(f.read())
|
doc = html.fromstring(f.read())
|
||||||
print(doc)
|
|
||||||
for data in doc.xpath('//table[tr/td/div[@class="stil2"]]'):
|
for data in doc.xpath('//table[tr/td/div[@class="stil2"]]'):
|
||||||
print('here1')
|
|
||||||
if counter <= 0:
|
if counter <= 0:
|
||||||
break
|
break
|
||||||
|
|
||||||
id = ''.join(data.xpath('./tr/td/div[@class="stil2"]/a/@href')).strip()
|
id = ''.join(data.xpath('./tr/td/div[@class="stil2"]/a/@href')).strip()
|
||||||
print('here', id)
|
|
||||||
if not id:
|
if not id:
|
||||||
continue
|
continue
|
||||||
|
id = id[7:]
|
||||||
cover_url = ''.join(data.xpath('./tr/td[1]/a/img/@src'))
|
cover_url = ''.join(data.xpath('./tr/td[1]/a/img/@src'))
|
||||||
if cover_url:
|
if cover_url:
|
||||||
cover_url = 'http://www.beam-ebooks.de' + cover_url
|
cover_url = 'http://www.beam-ebooks.de' + cover_url
|
||||||
title = ''.join(data.xpath('./tr/td/div[@class="stil2"]/a/b/text()'))
|
title = ''.join(data.xpath('./tr/td/div[@class="stil2"]/a/b/text()'))
|
||||||
author = ' '.join(data.xpath('./tr/td/div[@class="stil2"]/child::b/text()|./tr/td/div[@class="stil2"]/child::strong/text()'))
|
author = ' '.join(data.xpath('./tr/td/div[@class="stil2"]/child::b/text()|./tr/td/div[@class="stil2"]/child::strong/text()'))
|
||||||
price = ''.join(data.xpath('./tr/td[3]/text()'))
|
price = ''.join(data.xpath('./tr/td[3]/text()'))
|
||||||
print(data.xpath('./tr/td[3]/a/img/@alt'))
|
|
||||||
pdf = data.xpath('boolean(./tr/td[3]/a/img[contains(@alt, "PDF")]/@alt)')
|
pdf = data.xpath('boolean(./tr/td[3]/a/img[contains(@alt, "PDF")]/@alt)')
|
||||||
epub = data.xpath('boolean(./tr/td[3]/a/img[contains(@alt, "ePub")]/@alt)')
|
epub = data.xpath('boolean(./tr/td[3]/a/img[contains(@alt, "ePub")]/@alt)')
|
||||||
mobi = data.xpath('boolean(./tr/td[3]/a/img[contains(@alt, "Mobipocket")]/@alt)')
|
mobi = data.xpath('boolean(./tr/td[3]/a/img[contains(@alt, "Mobipocket")]/@alt)')
|
||||||
print(id, cover_url, title, author, price, pdf, epub, mobi)
|
|
||||||
counter -= 1
|
counter -= 1
|
||||||
|
|
||||||
s = SearchResult()
|
s = SearchResult()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user