- urlfile = urllib2.urlopen('<a href="http://www.commentcamarche.net/">http://www.commentcamarche.net/')
- print "Document type is", urlfile.info().getheader("Content-Type","")
- #输出:Document type is text/html
- print "HTTP Response headers:"
- print urlfile.info()
- #输出:
- #Document type is Date: Thu, 23 Mar 2006 15:13:29 GMT
- #Content-Type: text/html; charset=iso-8859-1
- #Server: Apache
- #X-Powered-By: PHP/5.1.2-1.dotdeb.2
- #Connection: close
- #该片段来自于http://www.codesnippet.cn/detail/110120131520.html
来源: http://www.codesnippet.cn/detail/110120131520.html