資源簡介
可以運行的高德地圖交通態勢爬取,代碼為爬取的大連市高新園區的交通態勢
代碼片段和文件信息
import?requests
import?pandas?as?pd
import?json
import?time
url?=?“https://restapi.amap.com/v3/traffic/status/rectangle?key=0488689d1ceeec1a994536d0953caf12&extensions=all&rectangle=“
baselng?=?121.513909
baselat?=?38.840823
widthlng?=?0.05
widthlat?=?0.04
x?=?[]
#?用于標識交通態勢線段
num?=?0
try:
????#?循環每個網格進行數據爬取
????for?i?in?range(0?6):
????????#?設定網格單元的左下與右上坐標的緯度值
????????#?在這里對數據進行處理,使之保留6位小數
????????startlat?=?round(baselat?+?i?*?widthlat?6)
????????endlat?=?round(startlat?+?widthlat?6)
????????for?j?in?range(0?6):
????????????#?設定網格單元的左下與右上坐標的經度值
????????????startlng?=?round(baselng?+?j?*?widthlng?6)
????????????endlng?=?round(startlng?+?widthlng?6)
????????????#?設置API的URL并進行輸出測試
????????????locStr?=?str(startlng)?+?““
- 上一篇:RNN網絡代碼
- 下一篇:Python打造網易云音樂器
評論
共有 條評論