Python Forum

Full Version: robobrowser, answer authentication-challenge after login
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm really new to python programming. I'm working on automation of a web-browser. I started with selenium, but found it to be really slow for what I need.

I'm working on a code that can Login to a webpage and fill out few text-boxes and click on few buttons. I finally achieved the 1st part. My program can finally sign to the webpage using the robobrowser.

import re
from robobrowser import RoboBrowser
browser = RoboBrowser()
login_url = 'https://webbroker.td.com/waw/idp/login.htm?execution=e1s1'
browser.open(login_url)
form = browser.get_form(id="login")
form["login:AccessCard"].value = "****"
form["login:Webpassword"].value = "****"
browser.submit_form(form)
As soon as I login to this webpage, it is asking me to answer an authentication question.

<div class="td-layout-row td-margin-top-medium">
<div class="td-layout-column td-layout-grid15"><label class="questionText" for="MFAChallengeForm:answer" id="MFAChallengeForm:question">
What is your favourite TV show?</label></div>
</div>
<div class="td-layout-row">
<div class="td-layout-column td-layout-grid7"><input autocomplete="off" id="MFAChallengeForm:answer" maxlength="25" name="MFAChallengeForm:answer" onkeydown="trapEnter(event,'MFAChallengeForm',id,'next')" size="25" type="password" value=""/></div>
</div>
How do I carry on form here? I need to enter and submit my authentication answer in order to proceed. In selenium, it would be something like this.

AQ = driver.find_element_by_id("MFAChallengeForm:answer")
AQ.send_keys("******")
*Click Submit*
how would I do it in robobrowser/lxml/beautifulsoup? I need to submit my answer(while sill being logged in). Most example that I have seen only scrape text from one specific web page. However is it possible to log in and keep on surfing the web?

Thank you in advance.