IP地址查询
前言:可以通过指定ip,来查看ip位置及运营商,目前发现以下三种方法【
淘宝ip地址查询
、百度ip地址查询
、太平洋IP地址查询
】,较为靠谱,其中推荐使用淘宝ip地址查询
的方法,百度ip地址查询
方法中的timestamp
未找到解决办法,有大佬解析出来的,欢迎在评论区指点指点。
测试使用:
1.联通: 175.43.56.12
2.电信: 183.166.103.89
3.移动: 218.204.153.156
4.国外: 103.12.161.38
第一种、淘宝ip地址查询[推荐
]
import requests
from fake_useragent import UserAgent
headers = {
'User-Agent': UserAgent().random
}
url = 'http://ip.taobao.com/outGetIpInfo'
data = {
'ip': '218.204.153.156',
'accessKey': 'alibaba-inc',
}
res = requests.post(url=url, headers=headers, data=data)
print(res.json())
第二种、百度ip地址查询(不过timestamp
的难点还没解决,会失效)
import json
import requests
from fake_useragent import UserAgent
headers = {
'User-Agent': UserAgent().random,
'timestamp': '2021-02-04T11:34:22Z@7681c588f9d3c2b8f32aabec9206aa86',
}
# timestamp:暂无解析办法
data = {
'ip': "175.43.56.12",
}
url = 'https://gwgp-kk6owjrbujz.i.bdcloudapi.com/ip2location/retrieve'
res = requests.post(url=url, headers=headers, data=json.dumps(data))
print(res.json())
第三种、太平洋IP地址查询
import requests
from fake_useragent import UserAgent
ip = '183.166.103.89'
headers = {
'User-Agent': UserAgent().random
}
url = 'http://whois.pconline.com.cn/ipJson.jsp?ip={}&json=true'.format(ip)
response = requests.get(url=url, headers=headers, timeout=3)
ret = response.json()
print(ret)
新手小白,代码写得不好,如果有理解错误的,还望大牛在评论区指出来,非常感谢!
以上就是 IP地址查询 的所有内容了,点赞收藏加评论是最大的支持哦!
📑编写不易,转载请注明出处,如有侵权,请联系我,邮箱(896263973@qq.com)!!!