简体   繁体   English

当浏览器给出404时,python库中的request模块给出的状态码为200

[英]request module in python library gives status code as 200 when the browser gives 404

Broswer shows page not found but request module gives 200 as status code 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]>

Given Two URL, the browser works fine for the first URL but gives error for the second one which it should but while checking the same with the python request module it gives 200 as status code for the both. 给定两个URL,浏览器对于第一个URL可以正常工作,但对于第二个URL却应该提供错误,但是在与python request模块检查相同的同时,它给出了两个的状态码。 Attached image for reference. 所附图片供参考。

YOU won't be able to open the URL as it is not accessible outside. 您将无法打开该URL,因为无法从外部访问该URL。

The site " http://abc.us.gib.com/tool/cluster.jsphttp://abc.us.gib.com/tool/cluster.jsp " returns wrong status code. 网站“ http://abc.us.gib.com/tool/cluster.jsphttp://abc.us.gib.com/tool/cluster.jsp ”返回错误的状态代码。 Requests module works fine. 请求模块工作正常。 You can check in a browser what status code above site returns. 您可以在浏览器中检查网站上方返回的状态代码。

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

相关问题 请求给出 404 而不是 200 - Requests gives 404 instead of 200 运行发布请求时,它给了我状态码 401 - When running a post request it gives me status code 401 Python POST 请求返回 404 状态代码,但 GET 请求返回 200 - Python POST Request returns 404 status code but GET request returns 200 通过 Python 的“请求”库发出 HTTP 请求时出现 404 状态代码。 但是页面在浏览器中加载良好 - 404 status code while making HTTP request via Python's “requests” library. However page is loading fine in browser Python请求循环,如果状态码不是200,则重试 - Python request loop, retry if status code not 200 urllib 请求给出 404 错误,但在浏览器中工作正常 - urllib request gives 404 error but works fine in browser gerrit 的 Rest api 给出了响应,但是用于获取修订的 Python-gerrit-api package 给出了状态 404 - Rest api of gerrit gives the response but Python-gerrit-api package for fetching revisions gives status 404 浏览器返回 200 而 requests.get 返回 403 - Browser gives 200 return while requests.get gives 403 从模块导入时,Python 3、5 / 2给出2而不是2.5 - Python 3, 5/2 when importing from module gives 2 and not 2.5 为什么在 python 中进行单元测试时,我期望状态代码为 200,但状态代码为 404? - Why am I expecting a status code of 200 but got a status code of 404 while unit testing in python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM