mirror of
https://github.com/lijiejie/eyes.sh.git
synced 2026-09-22 01:30:43 +08:00
修复ip归属地获取API失效
126网易API失效,提示dns未解析,现使用https://whois.pconline.com.cn/ 太平洋网络IP归属库API
This commit is contained in:
+2
-5
@@ -56,11 +56,8 @@ class MySQLLogger:
|
|||||||
return
|
return
|
||||||
ip = handler.client_address[0]
|
ip = handler.client_address[0]
|
||||||
try:
|
try:
|
||||||
doc = requests.get('http://ip.ws.126.net/ipquery?ip=%s' % ip).text
|
doc = requests.get('https://whois.pconline.com.cn/ip.jsp?ip=%s' % ip).text
|
||||||
doc = doc[doc.find('var localAddress=')+17:].strip()
|
city = doc.split(' ')[0]
|
||||||
doc = doc.replace('city', '"city"').replace('province', '"province"')
|
|
||||||
_doc = json.loads(doc)
|
|
||||||
city = _doc['province'] + ' ' + _doc['city']
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
city = ''
|
city = ''
|
||||||
log = DNSLog(user=user[0], host=domain.strip('.'), type=QTYPE[request.q.qtype], ip=ip, city=city)
|
log = DNSLog(user=user[0], host=domain.strip('.'), type=QTYPE[request.q.qtype], ip=ip, city=city)
|
||||||
|
|||||||
Reference in New Issue
Block a user