【发布时间】:2018-07-10 23:51:30
【问题描述】:
我编写了一个 python 脚本来验证来自主机的 url 连接。在 linux curl 中报告成功 (http 200) 的内容在 python (3.6) requests 模块中报告为 403。
我希望有人可以帮助我了解此处报告的 http 状态代码的区别?
来自 Linux 命令行的 Curl....
$ curl -ILs https://www.h2o.ai|egrep ^HTTP
HTTP/1.1 200 OK
Python 请求模块.....
>>> import requests
>>> url = 'https://www.h2o.ai'
>>> r = requests.get(url, verify=True, timeout=3)
>>> r.status_code
403
>>> requests.packages.urllib3.disable_warnings()
>>> r = requests.get(url, verify=False, timeout=3)
>>> r.status_code
403
【问题讨论】:
-
您要发送哪些标头?你收到什么标题? 403的原因可能在正文中进行了更详细的解释。
标签: python python-3.x curl python-requests