This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hello Friends!
I am trying to programmatically login to a website using Python Requests module (using latest versions of both requests and python at the time of writing). No matter what I try, it just doesn't seem to work. I am not getting any error message too.
Below is the code I have for reference.
import requests
# The url to login
URL = '<my url>'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0'
}
# These are private proxies
proxies = {
'http': 'http://username:password@url:port',
'https': 'https://username:password@url:port'
}
# Specify the email and password here
data = {
'inputs-newEmail': '<my email_id>',
'password': '<my password>'
}
with requests.Session() as session:
try:
post = session.post(
url=URL,
headers=headers,
proxies=proxies,
data=data
)
print(post.raise_for_status()) # Always returns None
except Exception as e:
print(e)
Below is the form details from the website I am trying to submit the post request. I notice that form and the div has an ID tag and it changes every time the page is refreshed. I don't know if this is causing any kind of problem.
I have even tried selenium but the send_keys commands do not send anything to the email and password fields.
This is the first time I am trying a post request like this and I am not sure what I am doing wrong. Kindly guide me.
Subreddit
Post Details
- Posted
- 4 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnpython...