Skip to content

Instantly share code, notes, and snippets.

@tomac4t
Last active April 3, 2024 12:33
Show Gist options
  • Save tomac4t/7d45b848b19e3d656e0c17a075fbdc2a to your computer and use it in GitHub Desktop.
Save tomac4t/7d45b848b19e3d656e0c17a075fbdc2a to your computer and use it in GitHub Desktop.
IPIP Firefox Extension API
#!/usr/bin/python3
import requests
import sys
n = len(sys.argv)
for i in range (1, n):
ipipapi = "https://btapi.ipip.net/host/info?ip=" + sys.argv[i] + "&host=&lang=cn"
headers = {
'User-Agent': 'ipip/tt',
'Accept-Encoding': 'gzip'
}
response = requests.get(ipipapi, headers=headers)
l1,l2,l3,l4,isp,lat,lng = response.json()['area'].split('\t')
print(sys.argv[i],l1,l2,l3,l4,isp,lat,lng,sep=',')
#!/usr/bin/python3
import requests
import sys
n = len(sys.argv)
for i in range (1, n):
ipipapi = "https://clientapi.ipip.net/browser/firefox?ip=" + sys.argv[i]
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Firefox/68.0',
}
response = requests.get(ipipapi, headers=headers, timeout=5)
data = response.json()['data']
print(sys.argv[i], data['country'], data['province'], data['city'], data['isp'], sep=',')
@tomac4t
Copy link
Author

tomac4t commented Apr 8, 2020

$ python3 ipip.py 95.142.161.63 185.100.87.251
95.142.161.63,法国,法兰西岛大区,巴黎,gandi.net
185.100.87.251,罗马尼亚,布加勒斯特,,flokinet.is
$ python3 ipip-bt.py 139.99.133.150 104.244.77.199 
139.99.133.150,澳大利亚,新南威尔士州,悉尼,,ovh.com,-33.868819,151.209295
104.244.77.199,卢森堡,卢森堡,,,buyvm.net,49.640991,6.05986

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment