您好,登錄后才能下訂單哦!
1、此api已經關閉
https://api.map.baidu.com/highacciploc/v1?qcip=220.181.38.113&ak=你申請的AK&extensions=1&coord=bd09ll
2、現在改成
API首頁:http://lbsyun.baidu.com/index.php?title=webapi/ip-api
使用方式:https://api.map.baidu.com/location/ip?ak=請輸入您的AK&coor=bd09ll
# -*- coding: utf-8 -*- import urllib import urllib2 import json import sys reload(sys) sys.setdefaultencoding('utf-8') class SendUrl(object): def send_url(self, url, headers, data=None): opener = urllib2.build_opener() request = urllib2.Request(url, data=data, headers=headers) response = opener.open(request, timeout=10) js = json.loads(response.read().decode("utf-8")) print(type(js)) #print(dir(js)) #print(js) print("================================================") print('位置:'+ js['content']['address_detail']['province'] + js['content']['address_detail']['city']) print('緯度:'+ js['content']['point']['y']) print('經度:'+ js['content']['point']['x']) print('節點:'+ js['address']) print("================================================") def Main(): # ak 需自行注冊 ak = "xxxxxxxxxxxxxxxxxxxxxxxxx" sx = SendUrl() url = "https://api.map.baidu.com/location/ip" data = {"ip": "36.101.234.14", "ak": ak, "coor": "bd09ll"} headers = { 'User-Agent': "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"} sx.send_url(url, headers, data=urllib.urlencode(data)) if __name__ == '__main__': Main()
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持億速云。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。