Change the way to address login form

Access the login form via its property "id" instead of its (changing) position, as it's not possible to use its name (this form has no name)
This commit is contained in:
Hervé M 2017-11-22 07:35:40 +01:00 committed by GitHub
parent 692c3297aa
commit 4fb5580990
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -144,10 +144,12 @@ class Mediapart(BasicNewsRecipe):
# -- Handle login
def get_browser(self):
def is_form_login(form):
return "id" in form.attrs and form.attrs['id'] == "logFormEl"
br = BasicNewsRecipe.get_browser(self)
if self.username is not None and self.password is not None:
br.open('https://www.mediapart.fr/login')
br.select_form(nr=2)
br.select_form(predicate=is_form_login)
br['name'] = self.username
br['password'] = self.password
br.submit()