Today you need to query the client IP nginx access is the same as scheduling!
First use the shell to intercept the IP in the file:
The Python script looks like this: (Haha, the novice wrote it hastily)
#!/usr/bin/env
#--Coding:utf-8-
Import JSON
Import Urllib
Import socket
Import Sys,os,re
Import Signal
url = "http://ip.taobao.com/service/getIpInfo.php?ip="
Def ip_list ():
IP_Address = []
With open ('/tmp/gcl/ip.txt ', ' R ') as F:
For IP in F.readlines ():
If IP! = None:
Ip_address.append (IP)
F.close ()
For I in IP_Address:
City_address = ip_local (i)
Print I.strip () + ":" + city_address
def ip_local (IP):
data = Urllib.urlopen (URL + IP). Read ()
Datadict=json.loads (data)
For Oneinfo in Datadict:
If "code" = = Oneinfo:
If datadict[oneinfo] = = 0:
return datadict["Data" ["City"]
Ip_list ()
Unfortunately, it's finished. You cannot redirect the results to a TXT file, manually copy ....
And that's how it turns out!
You can actually do all the work with a Python script ....
Wait till I get a little deeper.
Use Python to implement bulk query IP address attribution address