lundi 21 octobre 2019

How to get access to a webpage with multi-factor authentication using python

So I'm trying to access newclasses.nyu.edu to create a program that involves scraping the website but I need to first login with my student details and then enable MFA from my phone. How can I do this?

I have been able to get the user login details and store it in a dictionary but for some reason it shows invalid password

Getting user_data

def login():

login_data = {}

NetID = input("Enter your NetID")
password = input("Enter your password")

login_data['j_username'] = NetID
login_data['j_password'] = password 
login_data['_eventId_proceed'] = '' 

return login_data

with requests.Session() as s: #Maintain a session url = "https://newclasses.nyu.edu"

request = s.get(url) #Getting access to the site 

#soup = BeautifulSoup(request.content, 'html5lib') #Scraping the site 

login_data = login()
print(login_data)

request = s.get(url, data = login_data)

print(request.content)

This code prints out the webpage showing an invalid password but what I want is to be able to login and activate the MFA and get access to the site




Aucun commentaire:

Enregistrer un commentaire