使用Python下載指定頁面並自動將文件命名爲該URL
import httplib import os,sys def geturlcontent(url): conn=httplib.HTTPConnection(url) conn.request("GET","/") r=conn.getresponse() #i=r.getheader('server') content=r.read() path="c:/"+url+".html" f=file(path,"wb") f.write(content) f.close() conn.close() # print content url=sys.argv[1] geturlcontent(url)