我需要使用pycurl發送HTTP HEAD請求。如何使HEAD請求到pycurl
此代碼
curl = pycurl.Curl()
...
curl.setopt(curl.CUSTOMREQUEST, "HEAD")
curl.perform()
產生一個錯誤:
< HTTP/1.1 200 OK
* Server nginx/1.6.2 is not blacklisted
< Server: nginx/1.6.2
< Date: # No matters
< Content-Type: text/html; charset=utf-8
< Connection: keep-alive
< Cache-Control: no-cache,no-store,must-revalidate
< Pragma: no-cache
< Expires: # No matters
< Last-Modified: # No matters
< Content-Security-Policy: # No matters
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: # No matters
< X-Content-Type-Options: nosniff
< Content-Encoding: gzip
* no chunk, no close, no size. Assume close to signal end
<
* Operation timed out after 15001 milliseconds with 0 bytes received
* Closing connection 1
任何人可以幫助我嗎?
謝謝。我添加了'curl.setopt(curl.NOBODY,True)',它是可行的! – StasEvseev