mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update der Standard
Merge branch 'update_der_standard_and_fix_cover' of https://github.com/andy-5/calibre
This commit is contained in:
commit
fc687e9b14
@ -6,6 +6,7 @@ __copyright__ = '2009, Gerhard Aigner <gerhard.aigner at gmail.com>'
|
||||
|
||||
''' http://www.derstandard.at - Austrian Newspaper '''
|
||||
import re
|
||||
import random
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
from time import strftime
|
||||
|
||||
@ -47,8 +48,11 @@ class DerStandardRecipe(BasicNewsRecipe):
|
||||
(u'Meinung', u'http://derStandard.at/?page=rss&ressort=Meinung'),
|
||||
(u'Lifestyle', u'http://derStandard.at/?page=rss&ressort=Lifestyle'),
|
||||
(u'Reisen', u'http://derStandard.at/?page=rss&ressort=Reisen'),
|
||||
(u'Familie', u'http://derstandard.at/?page=rss&ressort=Familie'),
|
||||
(u'Greenlife', u'http://derStandard.at/?page=rss&ressort=Greenlife'),
|
||||
(u'Karriere', u'http://derStandard.at/?page=rss&ressort=Karriere'),
|
||||
(u'Immobilien', u'http://derstandard.at/?page=rss&ressort=Immobilien'),
|
||||
(u'Automobil', u'http://derstandard.at/?page=rss&ressort=Automobil'),
|
||||
(u'dieStandard', u'http://dieStandard.at/?page=rss&ressort=diestandard'),
|
||||
(u'daStandard', u'http://daStandard.at/?page=rss&ressort=dastandard')
|
||||
]
|
||||
@ -90,40 +94,14 @@ class DerStandardRecipe(BasicNewsRecipe):
|
||||
t.name = 'div'
|
||||
return soup
|
||||
|
||||
cover_re = re.compile('<img.*class="thumbnailBig.*src="(.*)" alt="issue"')
|
||||
|
||||
def get_cover_url(self):
|
||||
highResolution = True
|
||||
|
||||
date = strftime("%Y/%Y%m%d")
|
||||
# it is also possible for the past
|
||||
#date = '2012/20120503'
|
||||
|
||||
urlP1 = 'http://epaper.derstandarddigital.at/'
|
||||
urlP2 = 'data_ep/STAN/' + date
|
||||
urlP3 = '/V.B1/'
|
||||
urlP4 = 'paper.htm'
|
||||
urlHTML = urlP1 + urlP2 + urlP3 + urlP4
|
||||
|
||||
base_url = 'https://epaper.derstandard.at/'
|
||||
url = base_url + 'shelf.act?s=' + str(random.random() * 10000)
|
||||
br = self.clone_browser(self.browser)
|
||||
htmlF = br.open_novisit(urlHTML)
|
||||
htmlC = htmlF.read()
|
||||
|
||||
|
||||
# URL EXAMPLE: data_ep/STAN/2012/20120504/V.B1/pages/A3B6798F-2751-4D8D-A103-C5EF22F7ACBE.htm
|
||||
# consists of part2 + part3 + 'pages/' + code
|
||||
# 'pages/' has length 6, code has lenght 36
|
||||
|
||||
index = htmlC.find(urlP2) + len(urlP2 + urlP3) + 6
|
||||
code = htmlC[index:index + 36]
|
||||
|
||||
|
||||
# URL EXAMPLE HIGH RESOLUTION: http://epaper.derstandarddigital.at/data_ep/STAN/2012/20120504/pagejpg/A3B6798F-2751-4D8D-A103-C5EF22F7ACBE_b.png
|
||||
# URL EXAMPLE LOW RESOLUTION: http://epaper.derstandarddigital.at/data_ep/STAN/2012/20120504/pagejpg/2AB52F71-11C1-4859-9114-CDCD79BEFDCB.png
|
||||
|
||||
urlPic = urlP1 + urlP2 + '/pagejpg/' + code
|
||||
|
||||
if highResolution:
|
||||
urlPic = urlPic + '_b'
|
||||
|
||||
urlPic = urlPic + '.png'
|
||||
|
||||
return urlPic
|
||||
html = br.open(url).read()
|
||||
cover_match = self.cover_re.search(html)
|
||||
if cover_match is not None:
|
||||
cover_url = base_url + cover_match.group(1)
|
||||
return cover_url
|
||||
|
Loading…
x
Reference in New Issue
Block a user