How to login to the website by receiving email/password from the user in requests in python?

Viewed 34

I can login to website in requests with string in python. but i want to login by getting data from user

import requests

geturl = xxxqweasd.com

postData = {
    'email': 'xxxxsad@gmail.com',
    'password': 'sadsafdsafPass'
}

login = asd.post(getUrl, headers=headers, data=postData)

but i want this.

email= input("login your email:")
password = input("login your password:")
login = asd.post(getUrl, headers=headers, data=postData)

and done.

how can i do this?

edit:

It logs in first, then the 2FA screen comes up. then I want to enter that 2fa code.

first login with strings

then 2fa screen

and then i take 2fa code on email

and I enter the 2fa code.

1 Answers

You might want to read up on how variables and specifically dicts work on w3schools.

email= input("login your email:")
password = input("login your password:")
post_data = {
    'email': email,
    'password': password
}
login = asd.post(getUrl, headers=headers, data=post_data)
Related