python - 当浏览器给出 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,因为它在外部无法访问。
解决方案
站点“ http://abc.us.gib.com/tool/cluster.jsphttp://abc.us.gib.com/tool/cluster.jsp ”返回错误的状态码。请求模块工作正常。您可以在浏览器中查看站点上方返回的状态代码。
推荐阅读
- r - 如何在 R 的最小值的某个范围内找到向量中的值的数量?
- javascript - 当我以编程方式更新选择 UI 时,KnockoutJS 会触发更改事件
- ios - 如何根据 API 类型使用 BODY 发送 POST 或 GET 请求
- swift - 条件绑定的初始化程序必须具有可选类型,而不是“Bool”-firebase
- javascript - 为什么只执行一次onreadystatechange?
- tree - 从 bst 中删除节点时出现分段错误
- python - 如何在 Python 中使用 matplotlib 库翻译对象
- java - Spring JdbcTemplate - 如何预先为实现多租户的每个查询?
- javascript - 用画布中的形状动画线条
- ruby-on-rails - 当同一模型有两个 has_one 关联时,Rails 5 Form 无法正确保存