高德地图拥堵榜数据获取

1.中国主要城市拥堵排行(5分钟)实际获得前100名

url: https://report.amap.com/ajax/getCityRank.do

 代码

import pandas as pd
import requests
import time
while True:
    t = time.strftime("%H%M%S", time.localtime())
    r =requests.get("https://report.amap.com/ajax/getCityRank.do")
    s=r.json()
    a=[]
    for i in range(len(s)):
        a.append([s[i]["freeFlowSpeed"],s[i]["idx"],s[i]["idx1"],s[i]["idxRatio"],s[i]["label"],s[i]["name"],s[i]["rank1"],s[i]["rankState"],s[i]["realSpeed"],s[i]["value"],s[i]["idxRatioState"]])
    c = pd.DataFrame(a)
    c.to_csv(t+'road.csv')
    time.sleep(300)

结果

,0,1,2,3,4,5,6,7,8,9,10
0,46.96,1.99,1.99,35.0,烟台市,370600,1,up,23.62,0,up
1,44.5,1.98,2.2,18.0,乌鲁木齐,650100,0,down,22.46,1,up
2,46.09,1.97,1.98,40.0,邢台市,130500,2,flat,23.45,2,up
3,39.5,1.87,1.94,25.0,伊犁,654000,3,flat,21.16,3,up
4,46.03,1.77,1.77,5.0,成都市,510100,4,flat,26.02,4,up
5,43.68,1.74,1.65,21.0,邯郸市,130400,10,up,25.16,5,up
6,41.47,1.73,1.7,5.0,三亚市,460200,5,down,23.98,6,up
7,44.96,1.67,1.68,-1.0,深圳市,440300,6,down,26.88,7,down
8,51.7,1.67,1.68,7.0,重庆市,500000,7,down,31.03,8,up
9,48.35,1.65,1.67,-5.0,北京市,110000,8,down,29.34,9,down
。。。。。。。。。。。。。。
92,42.37,1.28,1.28,-13.0,金华市,330700,93,up,33.12,92,down
93,42.7,1.27,1.25,-6.0,滁州市,341100,95,up,33.75,93,down
94,49.03,1.27,1.29,-2.0,镇江市,321100,92,down,38.71,94,down
95,45.65,1.26,1.27,-9.0,嘉兴市,330400,94,down,36.27,95,down
96,48.21,1.25,1.25,-1.0,肇庆市,441200,96,flat,38.41,96,down
97,48.32,1.25,1.23,3.0,泰州市,321200,98,up,38.81,97,up
98,46.01,1.23,1.23,-8.0,湖州市,330500,99,up,37.53,98,down
99,51.28,1.23,1.24,1.0,南通市,320600,97,down,41.64,99,up

 每个城市的详情页获取,在前面的博客中已有提到

爬取高德地图路况信息,全国主要城市拥堵前10名的商圈和路段 - qq_912917507的博客 - CSDN博客

2.中国主要火车站周边道路实时拥堵榜(2分钟)实际80名

url:https://report.amap.com/ajax/congest/getHubs.do?linksType=11&prime=false&trafficid=&weekRadio=false

真是搞笑,我们把上面url的false改成true就有内容了,真是哈哈哈啦

代码和1.城市排行类似类似,不再赘述(其实是我懒得写了,哈哈哈)

更神奇的是当你点这个火车站就会进入详情页

url: https://report.amap.com/ajax/congest/getHubRoads.do?cityCode=【城市代码】&hubType=11&hubId=20 

具体获取方法和之前爬前10名道路的方法一样,就是想办法把给坐标对安排一个id,之后好利用id连接成线

3.中国主要机场周边道路实时拥堵榜(2分钟)实际75名

url:https://report.amap.com/ajax/congest/getHubs.do?linksType=12&prime=false&trafficid=&weekRadio=false

同理火车站的,有详情页 

https://report.amap.com/ajax/congest/getHubRoads.do?cityCode=【城市代码】&hubType=12&hubId=56

4.收费站,高速都是类似的(2分钟)实际100名

收费站https://report.amap.com/ajax/congest/getHubs.do?linksType=10&prime=false&trafficid=&weekRadio=false

高速https://report.amap.com/ajax/congest/getCongestRank.do?city=100000&prime=false&trafficid= 

我们都知道各大互联网地图公司的路况数据不是瓦片就是加密了,而这似乎是对于我这种小白来说最好的获取矢量路况的机会了

当然了,只有这一小段而已

5.景区 (2分钟)实际100名 

排行https://report.amap.com/ajax/congest/getHubs.do?linksType=41&prime=false&trafficid=&weekRadio=true

详情页就只有加密的路况了,我这种小白看不懂

6.全国高速安全驾驶风险路段挖掘(天)

危险驾驶https://report.amap.com/sanjiyisu/roads.do?type=0

超速路段https://report.amap.com/sanjiyisu/roads.do?type=100

运行状态突变常发路段https://report.amap.com/sanjiyisu/sdRoads.do

图上白点坐标https://report.amap.com/sanjiyisu/topPoints.do?type=0 

猜你喜欢

转载自blog.csdn.net/qq_912917507/article/details/85272929