From 8ca694376bd69c00abec88ab0e54403038060ed1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 25 Dec 2019 19:43:19 +0530 Subject: [PATCH] Put back login code for LRB since it is only open access temporarily --- recipes/lrb.recipe | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/recipes/lrb.recipe b/recipes/lrb.recipe index a43db65470..18db7c1d3b 100644 --- a/recipes/lrb.recipe +++ b/recipes/lrb.recipe @@ -28,6 +28,7 @@ class LondonReviewOfBooksPayed(BasicNewsRecipe): encoding = 'utf-8' INDEX = 'https://www.lrb.co.uk' publication_type = 'magazine' + needs_subscription = True requires_version = (3, 0, 0) keep_only_tags = [ @@ -38,6 +39,18 @@ class LondonReviewOfBooksPayed(BasicNewsRecipe): ] remove_attributes = ['width', 'height'] + def get_browser(self): + br = BasicNewsRecipe.get_browser(self) + if self.username and self.password: + br.open('https://www.lrb.co.uk/login') + br.select_form(id='login_form') + br['_username'] = self.username + br['_password'] = self.password + raw = br.submit().read() + if b'>My Account<' not in raw: + raise ValueError('Failed to login check username and password') + return br + def parse_index(self): articles = [] soup = self.index_to_soup(self.INDEX)