Skip to content

Instantly share code, notes, and snippets.

@ZJUGuoShuai
Created September 21, 2019 06:59
Show Gist options
  • Select an option

  • Save ZJUGuoShuai/4586beb03a45e88ffd4ed7b9efad7bcb to your computer and use it in GitHub Desktop.

Select an option

Save ZJUGuoShuai/4586beb03a45e88ffd4ed7b9efad7bcb to your computer and use it in GitHub Desktop.
"""
获取最新 IP 地址
运行需要 requests 库:
$ pip install requests
"""
import requests
import time
import hashlib
URL = "http://180.76.76.200/v3/resolve"
ACCOUNT_ID = "195462"
DN = "c6s%d.jamjams.net"
SECRET = "oc4CL3faMpRjEqSbiHVc"
T = str(int(time.time()) + 30 * 24 * 3600)
for i in range(1, 6):
SIGN = hashlib.md5(('-'.join([DN % i, SECRET, T])).encode('utf-8')).hexdigest()
params = {
'account_id': ACCOUNT_ID,
'dn': DN % i,
'sign': SIGN,
't': T
}
r = requests.get(URL, params=params).json()
if r['msg'] == 'ok':
print(r['data'][DN % i]['ip'][0], DN % i)
else:
print('Error!', DN % i)
print(r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment