【问题标题】:response 503 python requests响应 503 python 请求
【发布时间】:2020-08-04 08:49:11
【问题描述】:

您好,我尝试使用打击代码向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 秒,也无法正常工作 我该如何解决?

【问题讨论】:

  • 503 告诉你什么?
  • 我应该怎么罚款呢?当我尝试使用 Chrome 时,这很好,但在代码中我不知道我是初学者

标签: python python-3.x python-requests http-status-code-503


【解决方案1】:

因此,有时使用引用和谷歌缓存可以帮助您避免这些故障。所以你的代码应该是:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-09-22
    • 2021-10-01
    • 1970-01-01
    • 2017-03-18
    • 2020-02-24
    • 2018-05-22
    • 2014-05-07
    相关资源
    最近更新 更多