日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

python實(shí)現(xiàn)ip地址查詢經(jīng)緯度定位詳解

系統(tǒng) 1809 0

? 1、此api已經(jīng)關(guān)閉

https://api.map.baidu.com/highacciploc/v1?qcip=220.181.38.113&ak=你申請的AK&extensions=1&coord=bd09ll

2、現(xiàn)在改成

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('經(jīng)度:'+ js['content']['point']['x'])
    print('節(jié)點(diǎn):'+ 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()
          

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 肥城市| 淄博市| 库尔勒市| 罗田县| 将乐县| 霍州市| 安乡县| 灵武市| 离岛区| 徐水县| 探索| 梧州市| 翁牛特旗| 平泉县| 襄城县| 五原县| 通道| 壤塘县| 库伦旗| 贵州省| 阿坝| 新巴尔虎右旗| 卢氏县| 新野县| 汝南县| 海口市| 麟游县| 武安市| 穆棱市| 东乡县| 兴海县| 景谷| 海南省| 桂阳县| 中山市| 昌乐县| 开原市| 会理县| 镇赉县| 拜城县| 巴东县|