The year before the Fibonacci squat on the ground to look at you, laughing without words

Source: Internet
Author: User

My previous script to update the hosts.

Matches the comment at the beginning and the end of the comment.

Then the station master nothing to change the comments.

It turned out that my script was going to expire.

Then I have to correct it and resubmit it.

I'm sick of it when I change it a lot.

Would not bother to update the hosts.

I'm in a good mood today.

Open the script one look.

Why don't I just match the hosts content?

What's for his mother?

Ah?

You dare to look at the dog with a big eyes

119.161.83.27    google.com

It?

An IP, a newline character.

Ah?

Ah?

Do you want to note that there is an egg?

Ah?

R'(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} [^\n]+) \ n'

Ah??

1 #Encoding:utf-82 ImportUrllib3 ImportRe4 ImportOS5 6URL ='http://www.360kb.com/kb/2_122.html'7Regexhosts = R'(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} [^\n]+) \ n'8regextimeupdated = R'Google hosts (\d\d\d\d\.\d\d?\.\d\d?)'9 TenHostspath ='c:\\windows\\system32\\drivers\\etc\\hosts' One      A defretrievepage (URL): -     " "read the page source code. " " -Response =urllib.urlopen (URL) thepage =Response.read () -     returnpage -  - defmatchtimeupdated (page): +     " "match the hosts update time from the source of the page. " " -timeupdated =re.search (regextimeupdated, page) +     if  nottimeupdated: A         return 'Unknown time' at     Else: -         returnTimeupdated.group (1) -  - defmatchhostlist (page): -     " "match the host list from the source of the page. " " -result =re.findall (regexhosts, page, re. S) in      -     if  notResult: to         return '#Hosts Update Failed.\n#may resolved by update the script.' +     Else: -         returnresult the  * defconcatenatehosts (hosts): $     " "stitching the list into strings. " "Panax Notoginseng     return '\ n'. Join (hosts) -  the defAddextrainfo (srcstring, extraInfo): +     " "add additional information on the first line. " " A     returnExtraInfo +'\ n'+srcstring the  + defWrite2file (Hosts, FilePath): -     " "write to file. " " $f = open (FilePath,'W') $ F.write (Hosts) - f.close () -      the defrun (): -     " "The main run function. " "Wuyipage =retrievepage (URL) the      -hosts =matchhostlist (page) Wu      -ExtraInfo =" "#Hosts updated at%s About #Script written by [email Protected]://github.com/mlxy, feel-modify and distribute it. $ " "%matchtimeupdated (page) -Hostswithextra =Addextrainfo (Concatenatehosts (Hosts), ExtraInfo) -     - write2file (Hostswithextra, Hostspath) A      + if __name__=='__main__': the Run () -     Print 'finished.'
Ah???

Ah?

The year before the Fibonacci squat on the ground to look at you, laughing without words

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.