python获取高德地图全国区县编码
2019-02-04 17:40
281 查看
前端时间
跟着大神用百度爬取需要的poi数据,无耐被封,小弟菜鸟一个,暂时没弄懂代理IP池的构建方法,所以就只能转向高德,以下是用于获取全国指定城市的高德adcode编码
from bs4 import BeautifulSoup import requests,time,random with open('全国各省.txt','r') as f: g=f.read().split(',') ak='a32b3f70f49ba1f0435da3ce55c92016' # url='https://restapi.amap.com/v3/config/district?key=a32b3f70f49ba1f0435da3ce55c92016&keywords=贵州&subdistrict=2&extensions=base&ouput=json' # req=requests.get('https://restapi.amap.com/v3/config/district?key='+ak+'&keywords=贵州&subdistrict=2&extensions=base&ouput=json') for pro in g: time.sleep(random.randint(9,20)) req=requests.get('https://restapi.amap.com/v3/config/district?key='+ak+'&keywords='+pro+'&subdistrict=2&extensions=base&ouput=json') data=req.json() i=data['districts'][0]['districts'] dic={} print(pro) for ad in i: dis=ad['districts'] for area in dis: dic[area['name']]=area['adcode'] with open(pro+'县区代码.txt','a') as f: f.write(str(dic)) # with open('贵州省县区代码.txt','r+') as fr: # dic=eval(fr.read()) # print(dic.values())
相关文章推荐
- 【python】获取高德地图省市区县列表
- Python获取高德地图省市区县列表
- 获取高德地图省市区县列表
- 获取高德地图省市区县列表
- Android高德地图设置中心点图标,通过逆地理编码实时获取中心点的经纬度和详细位置
- python CGI模块获取中文编码问题解决- 部分方案
- Python获取字符串的编码
- 高德地图获取开发所需要的key
- [置顶] python CGI模块获取中文编码问题解决- 部分方案
- 高德地图地位获取地址
- 【python爬虫】尝试爬取-获取网站的编码信息(未完)
- 接入高德 SDK 遇到的问题 03:2D地图获取路线总时间、总距离
- 高德地图获取经纬度、高德地图坐标转为百度地图坐标
- python 获取系统相关编码的函数
- python requests爬取高德地图数据的实例
- 高德地图坐标的获取( JavaScript API )
- Python2获取中文文件名的编码问题
- python获取html编码GB2312中文乱码的问题
- python 获取网页编码方式实现代码
- python爬虫获取全国天气信息