小福利:不说明,不解释
#http://ncchc.dll.sourceforge.net/project/pyinstaller/2.0/pyinstaller-2.0.zip
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import platform
import os
import urllib2
def downloadHosts(url):
file = open('hosts.txt','w')
data=urllib2.urlopen(url).read()
file.write(data)
file.close()
def crosswall(url,system='Window'):
try:
if system == 'Windows':
file = open('%SystemRoot%\System32\drivers\etc\hosts.txt','w')
#data=urllib2.urlopen(url).read()
#file.write(data)
#file.close()
os.system('copy %SystemRoot%\System32\drivers\etc\hosts %SystemRoot%')
os.system('copy %SystemRoot%\System32\drivers\etc\hosts.txt %SystemRoot%\System32\drivers\etc\hosts' )
os.system('ipconfig /flushdns')
print 'It\'s done on windows! And Try your brower!'
elif system == 'Linux':
os.system('cp /etc/hodts /etc/hosts_bak')
os.system('mov ./hosts /etc/hosts' )
os.system('sudo /etc/init.d/networking restart ')
print 'It\'s done on Linux! And Try your brower!'
except Exception as e:
print e
if __name__=='__main__':
url = 'https://raw.githubusercontent.com/racaljk/hosts/master/hosts'
#downloadHosts(url)
crosswall(url,platform.system())