响应 503 python 个请求

response 503 python requests

您好,我正在尝试使用代码向 https://www.playerup.com/ 发送请求:

import requests
header = {"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36"}
r = requests.get("https://www.playerup.com/",headers=header)
print(r.status_code)

但它给我一个 [503] 类型错误 我尝试超时 5 秒但也不起作用 我该如何解决它?

因此,有时使用引荐来源网址和 google 缓存可以帮助您避免这些失败。所以你的代码应该是:

# here added a referer
header = {"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36" ,'referer':'https://www.google.com/'}
# now use a google cache
r = requests.get("http://webcache.googleusercontent.com/search?q=cache:www.playerup.com/",headers=header)

现在查看状态码:

>>>r
<Response [200]>