https://blog.csdn.net/weixin_38313931/article/details/81385542
POI是兴趣点,Point of Interest。
地址:http://lbsyun.baidu.com/apiconsole/quota#/home
开发者申请:
后面接上你的AK=?
Android SDK的Key的申请和使用:http://lbsyun.baidu.com/index.php?title=androidsdk/guide/key
步骤:
1.创建应用(服务器应用等)后,会自动配发一个Key(AK)
2.得到Key之后,就可以使用了,
import json from urllib.request import urlopen import time from urllib import request def urls(itemy, loc): #baidu_api = "你的秘钥" urls=[] for page in range(0,20): url = "http://api.map.baidu.com/place/v2/search?query=" + request.quote(itemy) + "&bounds=" + loc url = url + "&page_size=20&page_num=" + str(page) + "&output=json&ak=你的秘钥" urls.append(url) return urls def baidu_search(urls): try: json_sel = [] for url in urls: req = request.Request(url) json_obj = urlopen(req) data = json.load(json_obj) for item in data['results']: jname = item["name"] jlat = item["location"]["lat"] jlng = item["location"]["lng"] if "telephone" in item: jtel = item["telephone"].replace(',',' ') else: jtel = '' js_sel = jname + ',' + str(jlat) + ',' + str(jlng) + ',' + str(jtel) json_sel.append(js_sel) except: pass return json_sel def lat_all(loc_all): lat_sw = float(loc_all.split(',')[0]) lat_ne = float(loc_all.split(',')[2]) lat_list = [] for i in range(0, int((lat_ne - lat_sw ) / 0.01)): # 网格大小,可根据区域内POI数目修改 lat_list.append(lat_sw + 0.01 * i) lat_list.append(lat_ne) return lat_list def lng_all(loc_all): lng_sw = float(loc_all.split(',')[1]) lng_ne = float(loc_all.split(',')[3]) lng_list = [] for i in range(0, int((lng_ne - lng_sw ) / 0.01)): lng_list.append(lng_sw + 0.01 * i) lng_list.append(lng_ne) return lng_list def ls_com(loc_all): l1 = lat_all(loc_all) l2 = lng_all(loc_all) ab_list = [] for i1 in range(0, len(l1)): a = str(l1[i1]) for i2 in range(0, len(l2)): b = str(l2[i2]) ab = a + ',' + b ab_list.append(ab) return ab_list def ls_row(loc_all): l1 = lat_all(loc_all) l2 = lng_all(loc_all) ls_com_v = ls_com(loc_all) ls = [] for n in range(0, len(l1) - 1): for i in range(0 + len(l1) * n, len(l2) + (len(l2)) * n - 1): a = ls_com_v[i] b = ls_com_v[i + len(l2) + 1] ab = a + ',' + b ab_list = ab.split(',') if (ab_list[0] < ab_list[2] and ab_list[1] < ab_list[3]): ls.append(ab) return ls if __name__ == '__main__': print("开始爬取数据,请稍等...") start_time = time.time() loc = '23.1121, 113.3408, 23.1475, 113.3902' locs_to_use = ls_row(loc) i = 0 num = [] filepath = '你的路径\政府.txt' f = open(filepath, 'w',encoding='utf-8') for loc_to_use in locs_to_use: print(loc_to_use) i += 1 print("正在采集第%d个区域"%i) par = urls(u'政府', loc_to_use) print(par) a = baidu_search(par) b = len(a) num.append(b) print("第%d个区域采集数量为%d"%(i,b)) for ax in a: print('政府,' + ax) item = '政府,' + ax f.write(item) f.write("\n") end_time = time.time() print("爬取完毕,用时%.2f秒" % (end_time - start_time))
百度高德地图POI数据爬:https://blog.csdn.net/wanjiawen0260/article/details/81160283
百度地图POI数据获取:https://blog.csdn.net/dou3516/article/details/86517230
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
2016-10-26 TurtleBot教程