逐語大きな柱 https://www.dazhuanlan.com/2019/08/26/5d633ce17b786/
数日前に、いくつかのAPIを収集するために、第三者によって提供された結果の一部を提供しながら、腹腔内部のプロジェクト、IPIP使用プライマリ・データベース、クエリのページを提供するために、フォローアップクエリで
淘宝
推奨:5つ星
url: "http://ip.taobao.com/service/getIpInfo.php?ip="+ip
バックJSON形式データcode
0のフィールドは、主に、「領域」 '国、地理的位置データを含む、成功したクエリを示す 「領域」、「市」、「ISP」、 要求頻度が制限され、10PS以下であってはなりません
ルーチン:python
url = "http://ip.taobao.com/service/getIpInfo.php?ip="+ip
try:
r = requests.get(url, timeout=5)
except Exception, e:
result = {
"error": 1,
"msg": '请求失败'
}
return result
if r.status_code == requests.codes.ok:
data = r.json()
if data['code'] == 0:
t = data.get('data')
msg = [t.get('country',''), t.get('area',''), t.get('region',''), t.get('city',''), t.get('isp','')]
result = {
"error": data['code'],
"msg": ' '.join(msg),
"thirdpart": '淘宝'
}
シーナ
推奨度:4つ星
url: "http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip="+ip
jqueryの環境でJavaScriptの文を含む文字列を返し、直接取得および譲渡するgetScript()関数を使用することができます。主なデータは、地理的な「国」、「地域」、「都市」、「ISP」を含みます
ルーチン: python
url = "http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip="+ip
try:
r = requests.get(url, timeout=5)
except Exception, e:
result = {
"error": 1,
"msg": '请求失败'
}
return result
if r.status_code == requests.codes.ok:
data = r.text
content = data.split('=')[-1].strip()[:-1]
try:
t = simplejson.loads(content)
except Exception, e:
result = {
"error": 1,
"msg": '请求失败'
}
return result
msg = [t.get('country',''), t.get('province',''), t.get('city',''), t.get('isp','')]
result = {
"error": 0,
"msg": ' '.join(msg),
"thirdpart": '新浪'
}
太平洋のIPアドレスデータベース(pconline)
推奨度:3つ星
url: "http://whois.pconline.com.cn/ip.jsp?ip="+ip
ダイレクトリターン場所文字列は、当然のことながら、詳細を参照してください、異なるインタフェースを呼び出すことによって、異なるデータ形式を返すことができ、ここで
ルーチン:python
url = "http://whois.pconline.com.cn/ip.jsp?ip="+ip
try:
r = requests.get(url, timeout=5)
except Exception, e:
result = {
"error": 1,
"msg": '请求失败'
}
return result
if r.status_code == requests.codes.ok:
data = r.text
result = {
"error": 0,
"msg": data,
"thirdpart": 'pconline'
}
ip138
推奨度:4つ星
url: "http://test.ip138.com/query/?ip="+ip
これは、同じ地理的位置情報を含む文字列を返します
ルーチン:python
url = "http://test.ip138.com/query/?ip="+ip
try:
r = requests.get(url, timeout=5)
except Exception, e:
result = {
"error": 1,
"msg": '请求失败'
}
return result
if r.status_code == requests.codes.ok:
data = r.json()
if data.get("ret") == "ok":
msg = data.get("data")
result = {
"error": 0,
"msg": ' '.join(msg),
"thirdpart": 'ip138'
}
GeoIP
url: "http://geoip.nekudo.com/api/%s/zh" % ip
GeoIPを見て、この方法のpythonを含め、複数の言語を提供して呼び出し、データベースのオフライン版をダウンロードすることができていここオフラインバージョンを使用しない場合、このサイトは、JSON形式のデータルーチンを返す、APIを提供します。python
url = "http://geoip.nekudo.com/api/%s/zh" % ip
try:
r = requests.get(url, timeout=5)
except Exception, e:
result = {
"error": 1,
"msg": '请求失败'
}
return result
if r.status_code == requests.codes.ok:
data = r.json()
msg = [data.get("country",[]).get("name") or '', data.get("city") or '']
result = {
"error": 0,
"msg": ' '.join(msg),
"thirdpart": 'GeoIp'
}