在Python中通过登录页

2024-06-16 10:14:08 发布

您现在位置:Python中文网/ 问答频道 /正文

由于某些原因,我无法使用requests.Session()函数来保存登录凭据。我当前的代码不工作,我不知道为什么,有人能帮我纠正代码和解释所需的更改吗?我不想一个网站一个网站地不断寻求帮助

headers = {
    'Content-type': 'text/html',
    'User-Agent':'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.97 Safari/537.36',
    'origin':'https://stockinvest.us',
    'referer':'https://stockinvest.us'
    }
data = {'email':'user-email', 'password: 'user-password'}

with requests.Session() as s:
    login = s.post('https://stockinvest.us/login', data=data, headers=headers)
    s.cookies
    r = s.get('https://stockinvest.us/profile/edit')

Tags: 函数代码httpsdata网站emailsessionlogin