python - Python在发送请求时出现超时错误
问题描述
我实际上在一个项目上编写一个测试一些组合的程序。而且我总是遇到同样的错误==> HTTP错误408:请求超时
我做了一些研究,也许这是我的联系,但我有另一个想法。
这是我发送到页面的数据
data = "userLoginId={}&password={}&rememberMe=false&flow=websiteSignUp&mode=login&action=loginAction&withFields=rememberMe%2CnextPage%2CuserLoginId%2Cpassword%2CcountryCode%2CcountryIsoCode&authURL=authURL%2FEcpWPKhtag%3D&nextPage=&showPassword=&countryCode=%2B33&countryIsoCode=FR".format(email, password).encode("utf-8")
我认为问题来自 authURL :
&authURL=authURL
在此之前我修改了这一行,有一些随机文本,但我将其替换为“authURL”,因为我在另一个脚本上看到了它
这是整个请求:
request_login = urllib.request.Request("https://www.netflix.com:443/fr/Login",
data = data,
headers ={
'Host': 'www.netflix.com',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'fr-FR',
'Accept-Encoding': 'gzip, deflate, br',
'Referer': 'https://www.netflix.com/fr/Login',
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': 330},
unverifiable = True,
method = 'POST')
我希望我能成功发送带有代码 200 而不是 408 的请求
解决方案
最后,经过多次研究,这是因为数据必须是表格下的字典:(是的,只有那个)
data = {'email': email, 'password': password}
并且 auth URL 是错误的,但这与问题本身无关。
推荐阅读
- jquery - 如何在列表框中选择一个值并将其与其 optgroup 标签克隆到另一个列表框
- python - 如何使小部件随 PyQt5 中的窗口缩放?
- clojure - 在 Clojure 中使用 Java 哈希图
- machine-learning - Keras 中两次损失的总和(感知和 MSE)
- android - 访问 zzbgl 并覆盖已弃用的 API 时出错
- javascript - 使用 node.js 更正了大型 RESTful API 的可扩展结构
- go - 如何使用 Golang big.Int 计算`x^3 + ax + b mod p`
- angular - 动态创建 formGroupName 不起作用 - Angular 反应式表单
- ide - 关闭项目后pycharm配置丢失
- c++ - 我无法使用堆栈找到前缀数字的总和