mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Fix New Scientist login
This commit is contained in:
parent
0f34f3c593
commit
c1d261defb
@ -83,22 +83,19 @@ class NewScientist(BasicNewsRecipe):
|
|||||||
ans = BasicNewsRecipe.get_article_url(self, article)
|
ans = BasicNewsRecipe.get_article_url(self, article)
|
||||||
return ans.partition('?')[0]
|
return ans.partition('?')[0]
|
||||||
|
|
||||||
def is_login_form(self, form):
|
|
||||||
return "action" in form.attrs and form.attrs['action'] == "/ns-login.php"
|
|
||||||
|
|
||||||
def get_browser(self):
|
def get_browser(self):
|
||||||
br = BasicNewsRecipe.get_browser(self)
|
br = BasicNewsRecipe.get_browser(self)
|
||||||
if self.username is not None and self.password is not None:
|
if self.username is not None and self.password is not None:
|
||||||
br.open('http://www.newscientist.com/')
|
def is_login_form(form):
|
||||||
try:
|
return "action" in form.attrs and form.attrs['action'] == "/login/"
|
||||||
br.open('https://www.newscientist.com/login/')
|
|
||||||
br.select_form(predicate=self.is_login_form)
|
br.open('https://www.newscientist.com/login/')
|
||||||
br['log'] = self.username
|
br.select_form(predicate=is_login_form)
|
||||||
br['pwd'] = self.password
|
br['email'] = self.username
|
||||||
br.submit()
|
br['password'] = self.password
|
||||||
except:
|
res = br.submit().read()
|
||||||
self.log.exception(
|
if b'>Log out<' not in res:
|
||||||
'Unable to locate login form! Switching to free mode.')
|
raise ValueError('Failed to log in to New Scientist, check your username and password')
|
||||||
return br
|
return br
|
||||||
|
|
||||||
feeds = [
|
feeds = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user