I want to login to my account with the following structure:
import requests
session=requests.Session()
resp=session.get('https://mywebsite.com/login')
cont=resp.content
post_data={'user':'username', 'pass':'password'}
post_response=session.post(url='https://mywebsite.com/login', data=post_data}
print cont
The following error occurs:
Browser Error: Your browser version looks incompatible
Change your User-Agent
to something that the website thinks is compatible. You can do it like this,
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0'
}
r = session.post('https://mywebsite.com/login', data=post_data, headers=headers)
You have to send a correct User-Agent, for example:
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0',
}
post_response=session.post(url='https://mywebsite.com/login', data=post_data, headers=headers)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.