无法使用request.Session()。post登录

时间:2018-08-08 03:57:01

标签: python python-3.x web-scraping python-requests

我无法使用python成功通过此网页登录屏幕。我已经尝试了request.Session()。get和Selenium,但是由于其他错误,我目前甚至不能使用selenium。

如果我可以使用请求来完成登录,那么我希望这样做。我的代码如下:

with requests.Session() as s:
    p = s.post('https://www.chartmill.com/login.php', data=dict(
    username='username',
    password='password',
    ))

我将不胜感激,因为我无法解决任何问题。

2 个答案:

答案 0 :(得分:0)

该表单还同时提交submitID=1usernamepassword。试试:

with requests.Session() as s:
    p = s.post('https://www.chartmill.com/login.php', data=dict(
    username='username',
    password='password',
    submitID=1
    ))

答案 1 :(得分:0)

import json

import requests
headers = {"Content-Type": "application/json"}
data={
    'username':'username',
    'password':"password",
    }
with requests.Session() as s:
    p = s.post('https://www.chartmill.com/chartmill-rest/member/login', data=json.dumps(data),headers=headers)
judge= s.get('https://www.chartmill.com/account.php?o=74375').text.find(username)
print(judge)

正在工作。