Believe that there are a lot of people need to use Google to search, but the domestic wall is also more and more powerful, even the VPN has begun to be blocked, the following to everyone who can access Google's script without flipping the wall.
Script content:
VI google_update.py
#!/usr/bin/env python # coding:utf-8 # Author:toddlerya # Date:jan 2015 import urllib2 import RE import sys Os url = "http://www.360kb.com/kb/2_122.html" req = urllib2. Request (URL) html = Urllib2.urlopen (req). Read () Head_ver = Html.find (R ' <strong>google Hosts </strong ><strong> ') Ver_before = Len ("<strong>google hosts </strong><strong>") Tail_ver = Html.find (R ' </strong> update ') Head_span = Html.find (' #base services ') Tail_span = Html.find (' #google source End ') raw_hosts = Html[head_span:tail_span] result, Number = Re.subn (R ' <.*> ', ', raw_hosts) pure_hosts, number = RE . SUBN (R ' ', ', result] arch = "" 127.0.0.1 localhost # The following lines are desirable for IPV6 capable hosts:: 1
Ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 "" " Print "Update your host file start!" #print "Please input your su password" f = file (R '/tmp/hosts ', ' w+ ')
New_host = [arch,pure_hosts] F.writelines (new_host) f.close () os.system (' mv/tmp/hosts/etc/hosts ') print ' Update succes
S! "
The results are shown below: