简体   繁体   English

python request模块:head和get request方法之间有什么区别

[英]python requests module: what's the difference between head and get request method

when I use requests module to check whether a page is available. 当我使用请求模块检查页面是否可用时。 for example: 例如:

>>> import requests
>>> url = "http://www.motie.com/book/29675"
>>> res = requests.head(url)
>>> print res.status_code
404
>>> res = requests.get(url)
>>> print res.status_code
200

I got status_code 404 and 200 for HEAD and GET respectively. 我分别获得HEAD和GET的status_code 404和200。 I don't known why. 我不知道为什么。 besides, how can I strace the reason. 此外,我该如何寻找原因。 Thanks a lot. 非常感谢。

The web server you contact is free to behave as it feels it should. 您与之联系的Web服务器可以自由发挥其应有的作用。 In this case it reports that it cannot find an answer for the head request even if it can find an answer for the get request. 在这种情况下,它报告它找不到head请求的答案,即使它可以找到get请求的答案。 This is not what it should do, but you would need to fix the server to solve this issue. 这不是应该执行的操作,但是您需要修复服务器才能解决此问题。

See some more about the head request here and of course in the WP here . 在这里 ,当然还有在WP中,可以找到有关head要求的更多信息。

Actually, I think it is a bug in the server. 实际上,我认为这是服务器中的错误。

暂无
暂无

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

相关问题 导致此错误的python中的HTTPX和请求模块有什么区别 - What's the difference between HTTPX and requests module in python that is causing this error 通过Internet Explorer上的“查看源代码”和python中的request.get()方法所生成的html文本有什么区别? - What is the difference between html-text by “view source code” on Internet Explorer and by requests.get() method in python? df.head()和df.head有什么区别? - What's the difference between df.head() and df.head? --option和nargs ='有什么区别? 在Python的argparse模块中? - What's the difference between --option and nargs='?' in Python's argparse module? 此Javascript请求和Python请求之间有什么区别? - What's the difference between this Javascript request and Python request? Python模块和Python package有什么区别? - What's the difference between a Python module and a Python package? Python 3中的“函数”,“方法”和“绑定方法”之间有什么区别? - What's the difference between a 'function', 'method' and 'bound method' in Python 3? Python中的字符串方法和str方法有什么区别? - what's the difference between string method and str method in Python? 这些在Python中处理Unicode字符串的方法之间有什么区别? - What's the difference between these method to deal with Unicode strings in Python? groupby.first()和groupby.head(1)之间有什么区别? - What's the difference between groupby.first() and groupby.head(1)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM