首页 > 解决方案 > 当浏览器给出 404 时,python 库中的请求模块给出的状态代码为 200

问题描述

Broswer 显示未找到页面,但请求模块提供 200 作为状态码

In[23]:  requests.get("http://abc.us.gib.com/tool/cluster.jsp")
Out[23]: <Response [200]>
In[24]:  requests.get("http://abc.us.gib.com/tool/cluster.jsphttp://abc.us.gib.com/tool/cluster.jsp")
Out[24]: <Response [200]>

给定两个 URL,浏览器对第一个 URL 工作正常,但对第二个 URL 给出错误,但在使用 python 请求模块检查相同时,它给出 200 作为两者的状态码。附上图片供参考。

您将无法打开该 URL,因为它在外部无法访问。

标签: pythonpython-requestshttp-status-code-404

解决方案


站点“ http://abc.us.gib.com/tool/cluster.jsphttp://abc.us.gib.com/tool/cluster.jsp ”返回错误的状态码。请求模块工作正常。您可以在浏览器中查看站点上方返回的状态代码。


推荐阅读