Have you inspect login (dev-tools Chrome or FireFox),to see what happens when login?
The
With login there are many different methods and it easy to get stuck.
Requests doc Authentication has some about basic ones,eg Digest, OAuth 1 and 2,OpenId ect...
If i want to log in into this site.
The
Form Data
most be correct,and you may need a some Header data.json.dumps(payload)
is not needed Requests do serializing automatic as this is build in.With login there are many different methods and it easy to get stuck.
Requests doc Authentication has some about basic ones,eg Digest, OAuth 1 and 2,OpenId ect...
If i want to log in into this site.
import requests from bs4 import BeautifulSoup headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36' } params = { "username": "user_name", "password": "xxxxxxxxx", "remember": "yes", "submit": "Login", "action": "do_login", } with requests.Session() as s: s.post('https://python-forum.io/member.php?action=login', headers=headers, params=params) # logged in! cookies get saved for future requests response = s.get('https://python-forum.io/index.php') # cookies sent automatically! soup = BeautifulSoup(response.content, 'lxml') welcome = soup.find('span', class_="welcome").text print(welcome)
Output:Welcome back, snippsat. You last visited: Today, 07:29 PM Log Out