URL を指定してヘッダーを得る。
import urllib
import sys
url = sys.argv[1]
r = urllib.urlopen(url)
info = r.info()
for key in info.keys():
print key, ":", info[key]
実行結果:
^o^ > python httphead.py https://blog.panicblanket.com/ date : Sun, 03 Feb 2013 00:12:51 GMT connection : close content-type : text/html; charset=UTF-8 x-pingback : https://blog.panicblanket.com/xmlrpc.php server : Apache/2.2.23