Update Harper's Magazine

Fixes #1694742 [Updated recipe for Harper's magazine](https://bugs.launchpad.net/calibre/+bug/1694742)
This commit is contained in:
Kovid Goyal 2017-06-01 00:12:42 +05:30
parent 84e6d0bd9b
commit 24cc2f661c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1,5 +1,10 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
# vi: set fenc=utf-8 ft=python :
# kate: encoding utf-8; syntax python;
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2008-2013, Darko Miletic <darko.miletic at gmail.com>' __copyright__ = '2008-2017, Darko Miletic <darko.miletic at gmail.com>'
''' '''
harpers.org - paid subscription/ printed issue articles harpers.org - paid subscription/ printed issue articles
This recipe only get's article's published in text format This recipe only get's article's published in text format
@ -29,9 +34,9 @@ class Harpers_full(BasicNewsRecipe):
language = 'en' language = 'en'
encoding = 'utf8' encoding = 'utf8'
needs_subscription = 'optional' needs_subscription = 'optional'
masthead_url = 'http://harpers.org/wp-content/themes/harpers/images/pheader.gif' masthead_url = 'https://harpers.org/wp-content/themes/harpers/images/pheader.gif'
publication_type = 'magazine' publication_type = 'magazine'
LOGIN = 'http://harpers.org/wp-admin/admin-ajax.php' LOGIN = 'https://harpers.org/wp-admin/admin-ajax.php'
extra_css = """ extra_css = """
body{font-family: adobe-caslon-pro,serif} body{font-family: adobe-caslon-pro,serif}
.category{font-size: small} .category{font-size: small}
@ -52,17 +57,17 @@ class Harpers_full(BasicNewsRecipe):
def get_browser(self): def get_browser(self):
br = BasicNewsRecipe.get_browser(self) br = BasicNewsRecipe.get_browser(self)
br.open('http://harpers.org/') br.open('https://harpers.org/')
if self.username is not None and self.password is not None: if self.username is not None and self.password is not None:
tt = time.localtime() * 1000 tt = time.localtime() * 1000
data = urllib.urlencode({'action': 'cds_auth_user', 'm': self.username, 'p': self.password, 'rt': 'http://harpers.org/', 'tt': tt data = urllib.urlencode({'action': 'cds_auth_user', 'm': self.username, 'p': self.password, 'rt': 'https://harpers.org/', 'tt': tt
}) })
br.open(self.LOGIN, data) br.open(self.LOGIN, data)
return br return br
def parse_index(self): def parse_index(self):
# find current issue # find current issue
soup = self.index_to_soup('http://harpers.org/') soup = self.index_to_soup('https://harpers.org/')
currentIssue = soup.find('div', attrs={'class': 'mainNavi'}).find( currentIssue = soup.find('div', attrs={'class': 'mainNavi'}).find(
'li', attrs={'class': 'curentIssue'}) 'li', attrs={'class': 'curentIssue'})
currentIssue_url = self.tag_to_string(currentIssue.a['href']) currentIssue_url = self.tag_to_string(currentIssue.a['href'])