高德2python爬取了高德地圖一些地點的數據,爬出來數據大致情況如下:


 

 高德2python爬取了高德地圖一些地點的數據,爬出來數據大致情況如下:

 

日蘭高速-鼠標點擊坐標(Lng,Lat):116.463649,35.523882

石橋鎮-鼠標點擊坐標(Lng,Lat):116.724574,35.303396

 

https://www.opengps.cn/Map/Tools/PickUpGPS_AMap.aspx

 高德地圖獲取地圖坐標(GCJ-02坐標) - openGPS.cn

開發指南
https://lbs.amap.com/faq/webservice/webservice-api/poi-search/43253 開發 > URI API > 開發指南 > 

https://lbs.amap.com/faq/webservice/webservice-api/poi-search/43253

https://ditu.amap.com/search?query=%E6%99%AF%E7%82%B9&city=370800&geoobj=116.583955%7C35.40458%7C116.591659%7C35.40905&_src=around&zoom=17

搜索 - 高德地圖

https://ditu.amap.com/search?query=美食&city=370800&geoobj=116.583955%7C35.40458%7C116.591659%7C35.40905&_src=around&zoom=17

搜索 - 高德地圖
https://uri.amap.com/nearby 高德地圖周邊
https://lbs.amap.com/ 高德開放平台 | 高德地圖API
https://lbs.amap.com/api/uri-api/guide/search/around-search 
周邊生活服務頁-搜索相關-開發指南-URI API | 高德地圖API
https://lbs.amap.com/api/javascript-api/summary 概述-地圖 JS API | 高德地圖API
https://lbs.amap.com/demo-center/loca-api 數據可視化 JS API 示例中心
https://console.amap.com/dev/order/invoice 高德控制台
https://console.amap.com/dev/key/app 高德控制台
https://lbs.amap.com/api/loca-api/prod_intro 產品介紹-數據可視化 JS API

 

 

python爬取了高德地圖一些地點的數據,爬出來數據大致情況如下:

下面是基本流程:

1、注冊成為高德地圖API開發者,網址http://lbs.amap.com/(主要是獲取自己的keywords [注冊流程可以參考這個網址 https://lbs.amap.com/api/webservice/guide/create-project/get-key])。

2.安裝網絡爬取第三方庫,主要是下面三個(pip install 安裝);

from urllib.parse import quote

from urllib import request

import json

3.創建網絡爬蟲爬取數據,並對數據進行解析(這塊就直接上代碼了);

from urllib.parse import quote

from urllib import request

import json

# import xlwt

web_key = '**********'    #自己高德的地圖的key密鑰

url = "http://restapi.amap.com/v3/place/text"

cityname = "南京"      #  自己需要搜索城市

classfiled = "汽車站"   # 自己需要搜索的目的地信息(比如想搜索醫院,直接替換成醫院即可)

i=0            # 爬取的頁面信息,i=2時即爬取第2頁的數據。當 result['count']=0 時即此頁面已經無信息,爬取所有數據時可以用此終止循環

req_url = url + "?key=" + web_key + '&extensions=all&keywords=' + quote(classfiled) + '&city=' + quote(cityname) + '&citylimit=true' +                     '&offset=25' + '&page=' + str( i)+ '&output=json'

data = ''

f=request.urlopen(req_url)

data = f.read()

data = data.decode('utf-8')

result=json.loads(data)

#  print(result['count'])   # 等於0時,即代表此頁面已經無信息

result['pois'][0]    #顯示數據記錄格式

處理過會,基本的網頁信息就出來了

285e8df5a202

以上的數據是以字典的形式打印出來的,把自己需要獲取的字段提出出來就可以了:

for i in range(len(result['pois'])):

print('名稱:',result['pois'][i]['name']

,'\n類型:',result['pois'][i]['type']

,'\n省份:',result['pois'][i]['pname']

,'\n城市:',result['pois'][i]['cityname']

,'\n地區:',result['pois'][i]['adname']

,'\n鄉鎮:',result['pois'][i]['business_area']

,'\n詳細地址:',result['pois'][i]['address']

,'\n經緯度:',result['pois'][i]['location']

,'\n圖片鏈接:',result['pois'][i]['photos'][0]['url']

,'\n'

)

部分數據結果如下:

 

 

 

https://www.opengps.cn/Map/Tools/PickUpGPS_AMap.aspx

 高德地圖獲取地圖坐標(GCJ-02坐標) - openGPS.cn

日蘭高速-鼠標點擊坐標(Lng,Lat):116.463649,35.523882

石橋鎮-鼠標點擊坐標(Lng,Lat):116.724574,35.303396

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM