免翻墙上google(python3.3版)已打包

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#-*-coding:utf-8-*-
#python3.3.5
import urllib.request,os,time,platform,shutil,re
url='http://www.360kb.com/kb/2_150.html'
_360kb = urllib.request.urlopen(url)
status = _360kb.code
if platform.uname()[0]=='Windows':
    file = r'c:\windows\system32\drivers\etc\hosts'
else:
    file = r'/etc/hosts'
print('-------------------------------------------')
print('-----                                 -----')
print('-----                                 -----')
if status == 200 :
    html = str(_360kb.read())
    a = html.find('#google-hosts-2015')
    b = html.find('#google-hosts-2015-end')
    html = html[a:b]
    html = html.replace('<br />', '').replace('&nbsp;', '').replace('<span>', '').replace('</span>', '').replace('\\n', '\n')
   
    re_h = re.compile('</?\w+[^>]*>')#HTML标签
    html = re_h.sub('',html) #去掉HTML 标签
    shutil.copyfile(file, '%s.bak-%s'%(file, time.strftime('%Y%m%d%H%M%S')))
    output = open(file, 'w') 
    output .write(html)
    output .close()
    print('-----             执行成功            -----')
else:
    print('-----            执行失败             -----')
print('-----                                 -----')
print('-----                                 -----')
print('-------------------------------------------')
time.sleep(5)