Fuck anti-scrapping
A lot of similar forms in the source (ten...), with a hidden value to validate a real user (form selected by javascript). But we are lucky, this id can be read is the newsletter form or in the free call form.
This commit is contained in:
parent
2693b563a8
commit
6d0dd80522
1 changed files with 7 additions and 0 deletions
|
|
@ -47,11 +47,18 @@ class LoginPage(BasePage):
|
||||||
captcha = self.document.xpath('//label[@class="label_captcha_input"]')
|
captcha = self.document.xpath('//label[@class="label_captcha_input"]')
|
||||||
if len(captcha) > 0:
|
if len(captcha) > 0:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
form_newsletter = self.document.xpath('//form[@id="newsletter_form"]')[0]
|
||||||
|
hidden_input = form_newsletter.xpath('./input[@type="hidden"]')[0]
|
||||||
|
hidden_id = hidden_input.attrib["value"]
|
||||||
|
hidden_name = hidden_input.attrib["name"]
|
||||||
|
|
||||||
# Form without name
|
# Form without name
|
||||||
self.browser.select_form(predicate=self._predicate_form)
|
self.browser.select_form(predicate=self._predicate_form)
|
||||||
self.browser.set_all_readonly(False)
|
self.browser.set_all_readonly(False)
|
||||||
self.browser['login[username]'] = login.encode('iso-8859-1')
|
self.browser['login[username]'] = login.encode('iso-8859-1')
|
||||||
self.browser['login[password]'] = password.encode('iso-8859-1')
|
self.browser['login[password]'] = password.encode('iso-8859-1')
|
||||||
|
self.browser[hidden_name] = hidden_id
|
||||||
self.browser.submit(nologin=True)
|
self.browser.submit(nologin=True)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue