"Auxiliary program" practiced hand applet: Record the dynamic IP address of the outside network

Source: Internet
Author: User

Practiced Hand Small programprogram function: Real-time recording of IP;1, the timing to obtain the external network IP, stored in local files;Writing ideas: 1) Collect API interface to get extranet http://bbs.125.la/thread-13838979-1-1.html2) timed executionhttp://blog.csdn.net/imzoer/article/details/8699083/4) Log local files

1 #-*-coding:utf-8-*-2 #-*-CODING:GBK-*-3 #Date:2016/4/274 #Created by En5 6  fromThreadingImportTimer7 Import Time8 ImportUrllib29 ImportReTen """ One Count Counter A """ -Timecount =0 -Timer_interval=1 the """ - Recording Time - Access IP interface remove IP - Write Time + IP to ipcount+time.txt file + """ - defGetIP (): +Nowtime = Time.strftime ("%y-%m-%d%h:%m:%s", Time.localtime ()) AResponse = Urllib2.urlopen ('https://ipip.yy.com/get_ip_info.php'). Read () atCurrentip = Re.search ('\d+\.\d+\.\d+\.\d+', Response). Group (0) -f = open ("Ipcount+time.txt","a") -F.writelines (Nowtime +"the current IP address is:"+ Currentip +"\ n") -t=Timer (Timer_interval,getip) - T.start () - """   in Loop Execution Code - set the network IP to take once every once in a while to """ +  whileTrue: -Time.sleep (5) the GetIP () *Timecount + =Timer_interval $ Print("Program Run%s time"% Timecount)

"Auxiliary program" practiced hand applet: Record the dynamic IP address of the outside network

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.