python3请求400个错误请求
我正试图用请求登录到网页,但我得到了这个原因(400个错误请求) 我尝试的是: Google Chrome inspect的第一件事: 我的代码:python3请求400个错误请求,python,python-requests,Python,Python Requests,我正试图用请求登录到网页,但我得到了这个原因(400个错误请求) 我尝试的是: Google Chrome inspect的第一件事: 我的代码: import requests from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) headers = {
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
headers = {
"Content-Type":"application/x-www-form-urlencoded",
"User-Agent" : "Mozilla/5.0",
"Referer": "https://doit.voicemail.centurylink.net/login",
}
data = {
"DirectoryNumber": "1234567890",
"Password": "1234567890",
"next": "/"
}
with requests.Session() as c:
response = c.post(url='https://doit.voicemail.centurylink.net/login',
headers=headers,
data=data,
verify=False)
print(response.history, response.url, response.status_code, response.reason)
我如何才能做到这一点?我访问了您的网站,发现您发送数据的方式可能是:
data = MultipartEncoder(
fields=(
('DirectoryNumber', '1234567890'),
('Password', '1234567890'),
('next', '/')
)
)
with requests.Session() as c:
response = c.post(url='https://doit.voicemail.centurylink.net/login',
headers=headers,
data=data,
verify=False)
也许您必须指定的不是“下一步”,而是“重定向到”也许您必须发送JSON?为此使用json=data而不是data=datapurpose@D.Peter我也尝试了(json=data),但都是一样的。400错误的请求错误:raise TypeError(repr(o)+“不是JSON可序列化的”)TypeError:不是JSON可序列化的。我现在用重定向到替换:next。现在我得到了新的错误:[]200我使用的是:data={“DirectoryNumber”:“123456789”,“Password”:“123456789”,“redirectTo”:“}这可能是因为您的平台的标识符无效,我不知道