This commit is contained in:
Kovid Goyal 2013-01-29 14:31:44 +05:30
parent 71e77b85d7
commit a42c073e27

View File

@ -38,37 +38,24 @@ class HBR(BasicNewsRecipe):
#articleAuthors{font-family:Georgia,"Times New Roman",Times,serif; font-style:italic; color:#000000;font-size:x-small;} #articleAuthors{font-family:Georgia,"Times New Roman",Times,serif; font-style:italic; color:#000000;font-size:x-small;}
#summaryText{font-family:Georgia,"Times New Roman",Times,serif; font-weight:bold; font-size:x-small;} #summaryText{font-family:Georgia,"Times New Roman",Times,serif; font-weight:bold; font-size:x-small;}
''' '''
use_javascript_to_login = True
def get_browser(self): def javascript_login(self, br, username, password):
br = BasicNewsRecipe.get_browser(self) from calibre.web.jsbrowser.browser import Timeout
self.logout_url = None
#'''
br.open(self.LOGIN_URL)
br.select_form(name='signin-form')
br['signin-form:username'] = self.username
br['signin-form:password'] = self.password
raw = br.submit().read()
if '>Sign out<' not in raw:
raise Exception('Failed to login, are you sure your username and password are correct?')
try: try:
link = br.find_link(text='Sign out') br.visit('https://hbr.org/login?request_url=/', timeout=20)
if link: except Timeout:
self.logout_url = link.absolute_url pass
except: br.click('#accordion div[tabindex="0"]', wait_for_load=False)
self.logout_url = self.LOGOUT_URL f = br.select_form('#signin-form')
#''' f['signin-form:username'] = 'test-account'
return br f['signin-form:password'] = 'testaccount'
br.submit(ajax_replies=3)
def cleanup(self):
if self.logout_url is not None:
self.browser.open(self.logout_url)
def map_url(self, url): def map_url(self, url):
if url.endswith('/ar/1'): if url.endswith('/ar/1'):
return url[:-1]+'pr' return url[:-1]+'pr'
def hbr_get_toc(self): def hbr_get_toc(self):
#return self.index_to_soup(open('/t/hbr.html').read()) #return self.index_to_soup(open('/t/hbr.html').read())