[英]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.