mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
empik store: update
This commit is contained in:
parent
28eedbe8a6
commit
b1a0b4e815
@ -1,10 +1,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
store_version = 8 # Needed for dynamic plugin loading
|
store_version = 9 # Needed for dynamic plugin loading
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2011-2017, Tomasz Długosz <tomek3d@gmail.com>'
|
__copyright__ = '2011-2019, Tomasz Długosz <tomek3d@gmail.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import re
|
import re
|
||||||
@ -41,7 +41,7 @@ class EmpikStore(BasicStoreConfig, StorePlugin):
|
|||||||
def open(self, parent=None, detail_item=None, external=False):
|
def open(self, parent=None, detail_item=None, external=False):
|
||||||
aff_root = 'https://www.a4b-tracking.com/pl/stat-click-text-link/78/58/'
|
aff_root = 'https://www.a4b-tracking.com/pl/stat-click-text-link/78/58/'
|
||||||
|
|
||||||
url = 'http://www.empik.com/ebooki'
|
url = 'https://www.empik.com/ebooki'
|
||||||
|
|
||||||
aff_url = aff_root + as_base64(url)
|
aff_url = aff_root + as_base64(url)
|
||||||
|
|
||||||
@ -58,14 +58,14 @@ class EmpikStore(BasicStoreConfig, StorePlugin):
|
|||||||
d.exec_()
|
d.exec_()
|
||||||
|
|
||||||
def search(self, query, max_results=10, timeout=60):
|
def search(self, query, max_results=10, timeout=60):
|
||||||
url = 'http://www.empik.com/ebooki/ebooki,3501,s?resultsPP={}&q={}'.format(max_results, quote(query))
|
url = 'https://www.empik.com/ebooki/ebooki,3501,s?sort=scoreDesc&resultsPP={}&q={}'.format(max_results, quote(query))
|
||||||
|
|
||||||
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())
|
||||||
for data in doc.xpath('//div[@class="search-list-item"]'):
|
for data in doc.xpath('//div[@class="search-content js-search-content"]/div'):
|
||||||
if counter <= 0:
|
if counter <= 0:
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -74,14 +74,14 @@ class EmpikStore(BasicStoreConfig, StorePlugin):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
cover_url = ''.join(data.xpath('.//a/img[@class="lazy"]/@lazy-img'))
|
cover_url = ''.join(data.xpath('.//a/img[@class="lazy"]/@lazy-img'))
|
||||||
author = ', '.join(data.xpath('.//div[@class="smartAuthorWrapper"]/a/text()'))
|
author = ', '.join(data.xpath('.//a[@class="smartAuthor"]/text()'))
|
||||||
title = ''.join(data.xpath('.//div[@class="name"]/a/@title'))
|
title = ''.join(data.xpath('.//div[@class="name"]/a/@title'))
|
||||||
price = ''.join(data.xpath('.//div[@class="price"]/text()'))
|
price = ''.join(data.xpath('.//div[@class="price ta-price-tile "]/text()'))
|
||||||
|
|
||||||
with closing(br.open('http://empik.com' + id.strip(), timeout=timeout/4)) as nf:
|
#with closing(br.open('https://empik.com' + id.strip(), timeout=timeout/4)) as nf:
|
||||||
idata = html.fromstring(nf.read())
|
# idata = html.fromstring(nf.read())
|
||||||
crawled = idata.xpath('.//a[(@class="chosen hrefstyle") or (@class="connectionsLink hrefstyle")]/text()')
|
# crawled = idata.xpath('.//a[(@class="chosen hrefstyle") or (@class="connectionsLink hrefstyle")]/text()')
|
||||||
formats = ','.join([re.sub('ebook, ','', x.strip()) for x in crawled if 'ebook' in x])
|
# formats = ','.join([re.sub('ebook, ','', x.strip()) for x in crawled if 'ebook' in x])
|
||||||
|
|
||||||
counter -= 1
|
counter -= 1
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ class EmpikStore(BasicStoreConfig, StorePlugin):
|
|||||||
s.title = title.split(' - ')[0]
|
s.title = title.split(' - ')[0]
|
||||||
s.author = author.strip()
|
s.author = author.strip()
|
||||||
s.price = price.strip()
|
s.price = price.strip()
|
||||||
s.detail_item = 'http://empik.com' + id.strip()
|
s.detail_item = 'https://empik.com' + id.strip()
|
||||||
s.formats = formats.upper().strip()
|
#s.formats = formats.upper().strip()
|
||||||
|
|
||||||
yield s
|
yield s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user