简体   繁体   English

响应 503 python 请求

[英]response 503 python requests

hi I trying to get a request to https://www.playerup.com/ with blow code:嗨,我试图用打击代码向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)

but it give me a [503]type error I trying timeout for 5 second and also not work how I should fix it?但它给了我一个 [503] 类型错误,我尝试超时 5 秒并且也不起作用我应该如何修复它?

So times using a referer and google cache can help you avoid these failures.所以有时使用引用和谷歌缓存可以帮助您避免这些故障。 So your code should be:所以你的代码应该是:

# 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)

Now see the status code:现在查看状态码:

>>>r
<Response [200]>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM