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