首页 > 解决方案 > 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 的请求

标签: pythonrequesturllib

解决方案


最后,经过多次研究,这是因为数据必须是表格下的字典:(是的,只有那个)

data = {'email': email, 'password': password}

并且 auth URL 是错误的,但这与问题本身无关。


推荐阅读