From a42c073e2761f846ff67af3255a4049aa3209b8a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 29 Jan 2013 14:31:44 +0530 Subject: [PATCH] ... --- recipes/hbr.recipe | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/recipes/hbr.recipe b/recipes/hbr.recipe index b80b0bace7..54c0f258d8 100644 --- a/recipes/hbr.recipe +++ b/recipes/hbr.recipe @@ -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;} #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): - br = BasicNewsRecipe.get_browser(self) - 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?') + def javascript_login(self, br, username, password): + from calibre.web.jsbrowser.browser import Timeout try: - link = br.find_link(text='Sign out') - if link: - self.logout_url = link.absolute_url - except: - self.logout_url = self.LOGOUT_URL - #''' - return br - - def cleanup(self): - if self.logout_url is not None: - self.browser.open(self.logout_url) + br.visit('https://hbr.org/login?request_url=/', timeout=20) + except Timeout: + pass + br.click('#accordion div[tabindex="0"]', wait_for_load=False) + f = br.select_form('#signin-form') + f['signin-form:username'] = 'test-account' + f['signin-form:password'] = 'testaccount' + br.submit(ajax_replies=3) def map_url(self, url): if url.endswith('/ar/1'): return url[:-1]+'pr' - def hbr_get_toc(self): #return self.index_to_soup(open('/t/hbr.html').read())