国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

python 調用百度地圖地點檢索webAPI

SKYZACK / 1242人閱讀

摘要:百度地圖提供了開放的,使用方法服務右上角登陸賬號點擊獲取密鑰創建應用填寫應用名稱白名單然后復制例如然后直接上代碼提供了種方式行政區劃區域檢索圓形區域檢索矩形區域檢索詳情可見詳情本文以為例市場深圳你的返回結果如下南山市場南新路廣東省深

百度地圖提供了開放的API,使用方法

WEB服務API

右上角登陸賬號 -> 點擊“獲取密鑰” -> “創建應用” -> 填寫應用名稱&白名單IP -> 然后復制AK(例如u2uqy7Gxui0XyBdcHLU0D3hQINLKokc0)

然后直接上代碼
API提供了3種方式

1 行政區劃區域檢索 2 圓形區域檢索 3 矩形區域檢索

詳情可見API詳情
本文以 1,3為例

import requests

url = "http://api.map.baidu.com/place/v2/search"
querystring = {"query":"市場","region":"深圳","output":"json","ak":"你的ak","page_size":20,"page_num":0}
response = requests.request("GET", url, params=querystring)
r = response.json()
print(r["results"])
print(len(r["results"]))

返回結果如下

[{"name": "南山市場", "location": {"lat": 22.531757, "lng": 113.926754}, "address": "南新路2008", "province": "廣東省", "city": "深圳市", "area": "南山區", "street_id": "d6df91c124f80073f7b9164d", "telephone": "13590117093", "detail": 1, "uid": "d6df91c124f80073f7b9164d"}, {"name": "筍崗文具玩具禮品批發市場", "location": {"lat": 22.564115, "lng": 114.114963}, "address": "寶安北路1025號", "province": "廣東省", "city": "深圳市", "area": "羅湖區", "street_id": "28e700f171893318095cb34a", "telephone": "(0755)82268844", "detail": 1, "uid": "28e700f171893318095cb34a"}, {"name": "嶂背綜合市場", "location": {"lat": 22.692344, "lng": 114.255645}, "address": "廣東省深圳市龍崗區嶂背路216號", "province": "廣東省", "city": "深圳市", "area": "龍崗區", "street_id": "4fc3161a8a8d3db03a13fd59", "detail": 1, "uid": "4fc3161a8a8d3db03a13fd59"}, {"name": "圳美市場", "location": {"lat": 22.796433, "lng": 113.951935}, "address": "廣東省深圳市光明區光明新區喜樂多百貨(康明路東)", "province": "廣東省", "city": "深圳市", "area": "光明區", "street_id": "5ffe414874a5986d9fec2b06", "detail": 1, "uid": "5ffe414874a5986d9fec2b06"}, {"name": "牛湖農貿市場", "location": {"lat": 22.730088, "lng": 114.095257}, "address": "觀瀾鎮牛湖村高爾夫大道旁", "province": "廣東省", "city": "深圳市", "area": "龍華區", "street_id": "8f6d8c61968269a36c47605b", "detail": 1, "uid": "8f6d8c61968269a36c47605b"}, {"name": "坪山綜合批發市場", "location": {"lat": 22.695807, "lng": 114.346117}, "address": "坪山區新區東縱路470號坪山批發市場公交車站旁六和工地", "province": "廣東省", "city": "深圳市", "area": "坪山區", "street_id": "550fd5f96c6d9060931fc955", "detail": 1, "uid": "550fd5f96c6d9060931fc955"}, {"name": "坪西市場", "location": {"lat": 22.765712, "lng": 114.292258}, "address": "吉祥一路23號", "province": "廣東省", "city": "深圳市", "area": "龍崗區", "street_id": "87248d96c13e62aa2806ce5a", "detail": 1, "uid": "87248d96c13e62aa2806ce5a"}, {"name": "友信冷凍食品城", "location": {"lat": 22.66691, "lng": 114.13473}, "address": "深圳市龍崗區南灣街道上李朗社區平吉大道78號", "province": "廣東省", "city": "深圳市", "area": "龍崗區", "street_id": "d8ef3b08c51b727a58bbbc69", "telephone": "(0755)88263688", "detail": 1, "uid": "d8ef3b08c51b727a58bbbc69"}, {"name": "石巖新村綜合市場", "location": {"lat": 22.679288, "lng": 113.930496}, "address": "深圳市寶安區王家莊市場1號301", "province": "廣東省", "city": "深圳市", "area": "寶安區", "street_id": "593850fb068b9720df1e526b", "detail": 1, "uid": "593850fb068b9720df1e526b"}, {"name": "新陂頭農貿市場", "location": {"lat": 22.807519, "lng": 113.948556}, "address": "深圳市光明區康弘路13號", "province": "廣東省", "city": "深圳市", "area": "光明區", "detail": 1, "uid": "3a0a78bd2b341d86631809d9"}, {"name": "愛華肉菜市場", "location": {"lat": 22.544775, "lng": 114.098053}, "address": "愛華路47號", "province": "廣東省", "city": "深圳市", "area": "福田區", "street_id": "b533ea4af6bb89584f6d4645", "telephone": "(0755)83620019", "detail": 1, "uid": "b533ea4af6bb89584f6d4645"}, {"name": "茜坑老村綜合市場", "location": {"lat": 22.69478, "lng": 114.036412}, "address": "新區觀瀾", "province": "廣東省", "city": "深圳市", "area": "龍華區", "street_id": "50fb64ff5a658e20e9f8531b", "telephone": "13885524446", "detail": 1, "uid": "50fb64ff5a658e20e9f8531b"}, {"name": "利民農貿批發市場", "location": {"lat": 22.742953, "lng": 114.289898}, "address": "廣東省深圳市龍崗區深惠路1256號", "province": "廣東省", "city": "深圳市", "area": "龍崗區", "street_id": "61f634f6fce2e8616a49f3aa", "detail": 1, "uid": "61f634f6fce2e8616a49f3aa"}, {"name": "龍崗第一市場", "location": {"lat": 22.73833, "lng": 114.287002}, "address": "廣東省深圳市龍崗區龍崗第一市場(龍崗大道西)", "province": "廣東省", "city": "深圳市", "area": "龍崗區", "street_id": "0143dd2b837c3381cf06a435", "detail": 1, "uid": "0143dd2b837c3381cf06a435"}, {"name": "回龍埔綜合市場", "location": {"lat": 22.736316, "lng": 114.241372}, "address": "深圳市龍崗區龍平西路26", "province": "廣東省", "city": "深圳市", "area": "龍崗區", "street_id": "d219bb1dc2beb792f50e775d", "telephone": "18926789088", "detail": 1, "uid": "d219bb1dc2beb792f50e775d"}, {"name": "公明綜合市場", "location": {"lat": 22.786351, "lng": 113.899172}, "address": "光明區公明街道振明路145-5", "province": "廣東省", "city": "深圳市", "area": "光明區", "detail": 1, "uid": "1eeed5464e94e5ebb5147f4c"}, {"name": "民治綜合街市", "location": {"lat": 22.630651, "lng": 114.045652}, "address": "深圳市龍華區民治大道412", "province": "廣東省", "city": "深圳市", "area": "龍華區", "street_id": "d0b8923fcf5d4bfbb5f42f5f", "detail": 1, "uid": "d0b8923fcf5d4bfbb5f42f5f"}, {"name": "荔園集貿批發市場", "location": {"lat": 22.698857, "lng": 114.141112}, "address": "平湖鎮景秀三巷7號", "province": "廣東省", "city": "深圳市", "area": "龍崗區", "street_id": "7ee3ccf7b8aed470047ce87c", "telephone": "(0755)28852881", "detail": 1, "uid": "7ee3ccf7b8aed470047ce87c"}, {"name": "富民鐵路市場", "location": {"lat": 22.617064, "lng": 114.126306}, "address": "廣東省深圳市龍崗區布李路164號", "province": "廣東省", "city": "深圳市", "area": "龍崗區", "street_id": "96e3e1a27685cb82cae33c57", "detail": 1, "uid": "96e3e1a27685cb82cae33c57"}, {"name": "鹽田海鮮批發市場", "location": {"lat": 22.590926, "lng": 114.284179}, "address": "深圳市鹽田區海鮮街28", "province": "廣東省", "city": "深圳市", "area": "鹽田區", "street_id": "fc7675243816e6e34f776ea2", "telephone": "(0755)25202868", "detail": 1, "uid": "fc7675243816e6e34f776ea2"}]

返回20條
page_size最大為20
page_num參數可以控制頁碼數
下面是重點!


但是通過行政區地點檢索 最多返回400個這是百度的限制
這時就需要 通過矩形區域檢索
將深圳劃分為多個區域進行檢索
a和b的坐標在這里定位坐標拾取網站

import requests
import time
import json
keyword = "菜市場"
city = "深圳"

url = "http://api.map.baidu.com/place/v2/search"
a = "22.4717881915,113.7808575851"
b = "22.7960248910,114.3961567319"
#a為深圳左下角坐標,b為深圳右上角坐標

left_bottom = [113.7808575851,22.4717881915] # 設置區域左下角坐標(百度坐標系)
right_top = [114.3961567319,22.7960248910] # 設置區域右上角坐標(百度坐標系)

part_n = 5 # 設置區域網格(5*5)

x_item = (right_top[0]-left_bottom[0])/part_n
y_item = (right_top[1]-left_bottom[1])/part_n
n = 0 # 切片計數器
url0 = "http://api.map.baidu.com/place/v2/search?"
data = []
for i in range(part_n):
     for j in range(part_n):
         left_bottom_part = [left_bottom[0]+i*x_item,left_bottom[1]+j*y_item]; # 切片的左下角坐標
         right_top_part = [right_top[0]+i*x_item,right_top[1]+j*y_item]; # 切片的右上角坐標
         for k in range(20):
             time.sleep(0.6)
             url = url0 + "query=" + "市場" + "&page_size=20&page_num=" + str(k) + "&scope=1&bounds=" + str(
                 left_bottom_part[1]) + "," + str(left_bottom_part[0]) + "," + str(right_top_part[1]) + "," + str(
                 right_top_part[0]) + "&output=json&ak=" + "你的ak"
             print(str(left_bottom_part[1]) + "," + str(left_bottom_part[0]))
             print(str(right_top_part[1]) + "," + str(right_top_part[0]))
             print("===================================================")
             response = requests.request("GET", url)
             response = response.json()
             print(response)
             r = response["results"]
             data.append(r)

這樣就可以突破深圳區域400的限制了,可以分為1010更細化 1010共返回1200+結果

文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。

轉載請注明本文地址:http://m.specialneedsforspecialkids.com/yun/43907.html

相關文章

  • 百度地圖的使用-定位—逆地理編碼(即坐標轉地址)

    摘要:先上效果定位拖動定位定位動畫動畫結束顯示地址實現思路中心點不變,在百度地圖圖層上覆蓋自定義的定位布局拖動地圖時,隱藏地址顯示,定位標示落下來后顯示地址拿到百度地圖的拖動監聽拿到中心點經緯度,逆地理編碼即坐標轉地址具體實現布局在主界面布局上覆 先上效果: 定位+拖動定位 定位動畫 動畫結束顯示地址 showImg(https://segmentfault.com/img/bVbcQ8...

    tylin 評論0 收藏0
  • 從地址字符串獲取省市區信息

    摘要:需求從手工填寫的地址中,解析出省市區信息方法使用百度地圖正逆地理編碼雖然百度地圖提供地點檢索,但是是需要傳入行政區信息的根據正地理編碼服務接口將地址轉換為經緯度,然后根據經緯度調用逆地理編碼服務接口,得到結構化的行政區信息代碼你的百度地圖返 需求: 從手工填寫的地址中,解析出省市區信息 方法 使用百度地圖api正/逆地理編碼PS: 雖然百度地圖提供地點檢索,但是是需要傳入行政區信息的 ...

    MartinHan 評論0 收藏0
  • vue異步加載高德地圖

    摘要:異步加載異步加載指的是為指定加載的回調函數,在的主體資源加載完畢之后,將自動調用該回調函數。 幾種加載js的方式 同步加載 異步加載 延遲加載 同步加載 用的最多的一種方式,又稱阻塞模式,會阻止瀏覽器的后續處理,停止后續的解析,只有當當前加載完成,才能進行下一步操作。所以默認同步執行才是安全的。但這樣如果js中有輸出document內容、修改dom、重定向等行為,就會造成頁面堵塞。...

    zacklee 評論0 收藏0

發表評論

0條評論

SKYZACK

|高級講師

TA的文章

閱讀更多
最新活動
閱讀需要支付1元查看
<