Mechanical Soup: Complex logins

231 Views Asked by At

I am trying to create a python script with mechanicalsoup to login to verizon.com. The login page itself loads just fine. The problem I am facing is the response after submitting my login. Verizon has a "please wait" loading screen after submitting credentials. So, when I print out the response to the login attempt, I am not greeted with my user dashboard or 2FA input field. I am instead only seeing the content of the "please wait" page when I print out the response. Is there a workaround for this without using something more robust like selenium?

Code:

import mechanicalsoup
import time

browser = mechanicalsoup.StatefulBrowser()
browser.set_user_agent('Mozilla/5.0')
browser.open("https://secure.verizon.com/vzauth/UI/Login")

browser.select_form('form[action="https://secure.verizon.com/vzauth/UI/Login"]')
browser.form.print_summary()
browser["IDToken1"] = "bobjohnson"
browser["IDToken2"] = "bobjohnson123"
resp = browser.submit_selected()
time.sleep(3)
print(resp.text)
0

There are 0 best solutions below