smarthosts自动更新
#coding: utf-8
#name: smarthosts自动更新
#author: [email protected]
#date: 2013-2-28 16:12:33
import shutil
import requests
#下载hosts
host_url = 'http://smarthosts.googlecode.com/svn/trunk/hosts'
r = requests.get(host_url)
hosts = r.text
#备份hosts
src = r'C:WindowsSystem32driversetchosts'
dst = r'C:WindowsSystem32driversetchosts_backup'
shutil.copyfile(src, dst)
f = open(src, 'w')
f.write(hosts)
f.close()
print Your hosts has been updated;