python/urllib2/ target=_blank class=infotextkey>python urllib2模块抓取信息的代码:
#!/usr/bin/env python
#
urlfile = urllib2.urlopen('http://www.plcxue.com/')
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