最近看了一份人民大学的报告,《中国城市政商关系排行榜2020》,https://new.qq.com/omn/20201230/20201230A0F3MY00.html。
讲的是中国各个城市的政商关系健康指数,决定拿这份报告中的数据,来做一份html的专题图。
效果如下(腾讯瓦片):
一、数据获取
参考腾讯web api:https://lbs.qq.com/service/webService/webServiceGuide/webServiceDistrict
脚本:
import requests
import time
# 获取省code和省name列表
def getAllProvince(key):
url = 'http://apis.map.qq.com/ws/district/v1/list?key='+key
reponse = requests.get(url=url)
reponse.encoding = 'utf-8'
data = reponse.json()
provincelist = []
for r in data['result'][0]:
provincelist.append(r['id']+'\t'+r['name'])
return provincelist
# 获取省围栏
def getProvincePolygon(key,provinceCode):
url = 'https://apis.map.qq.com/ws/district/v1/search?&keyword='+provinceCode+'&key='+key+'&get_polygon=2&max_offset=3000'
print(url)
reponse = requests.get(url=url)
reponse.encoding = 'utf-8'
data = reponse.json()
print(data)
path = data['resul