获取高德地图POI数据

完整代码如下,需要先行申请开发者KEY,代码先放在这里,开发思路以后有时间再详细写。
需要使用的话,可以下载下面编译好的程序
https://download.csdn.net/download/ashtyukjhf/18860618

import requests

class getPOI():
    def getPOIcore(self):
        url=u"https://restapi.amap.com/v3/place/text?parameters"
        r=requests.get(url, params=self.params)
        data=eval(r.text)
        self.count=int(data['count'])
        
        for poi in data['pois']:
            try:
                print(poi['id'],poi['name'],poi['adname'],poi['business_area'],poi['address'],poi['location'],poi['type'],sep=',',file=self.outfile)
            except :pass

    def __init__(self,region:str,keywords='',types=''):
        if keywords==types=='':
            print("类型和关键字不能同时为空")
        self.params={
            'key': '######请到高德开放平台申请#####',
            'keywords': keywords,
            'types':types,
            'region':region,
            'page':1,
            'city_limit':'true',
            'extensions':'all'
        }

        filename=region+keywords+types+'POI数据.csv'

        headers=['id','名称','区县','商圈','地址','经度,纬度','类型']

        with open(filename, mode='w+', encoding='utf-8') as self.outfile:
            print(*headers, sep=',',file=self.outfile)
            i=0
            while True:
                i+=1;
                self.params['page']=i
                self.getPOIcore()
                if i==1:
                    print(region,keywords,types,'总计数据',self.count,'条')
                if i>int(self.count/20):
                    break
            

        pass






print('使用说明:\n输入区域、关键字或类型,即可获取相应POI数据\n其中类型和关键字可有一项为空\n例如:\n区域:岳麓区\n关键字:\n类型:餐饮\n\n\n')
region=input('请指定区域:')
keywords=input('指定关键字:')
types=input('指定类型:')

getPOI(region=region,keywords=keywords,types=types)

input('数据获取完毕')
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

高堂明镜悲白发

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值