Python crawling high moral map POI data acquisition massage bath [Guide]

Original link: https://mp.weixin.qq.com/s?src=11×tamp=1571813510&ver=1929&signature=EnGAU4Tev3LBx7mMrPbPB-D71kbhVUmHXRgCUHoZBYSWPKeKN4BXkYN79M4PvlDBU5yaAE047sS9f8nUZS3k6Vh0iHJ-H2C96Yb90yU0kp34FEMvIA*Y3G87Tvaflri6&new=1

Recognized high moral map API

Open the "high German open platform", click on the "development of the document" to find and click the "Search API" in the "Web services."
Here Insert Picture Description
We use the "Search API", in order to crawl POI. The so-called POI, ie, "Point of Interest", Chinese called "points of interest." POI are divided into various types, such as schools, shopping malls, delivery points and so on. Here we are with massage bath [place], for example. There are three main parameters:

  • key: Key High German, which is the authorized person of high moral certified to use their API services
  • types: POI types, different types have different encoding properties such as massage bathing is 071400
  • city: city code, that is, before the ID number 6, as encoded Qidong is 320 681
    Here Insert Picture Description
    Here Insert Picture Description

Data crawling

Below Qidong City, Jiangsu Province, to see how crawling POI data for a single county-level units.

import requests            # 导入各模块
import json
import pandas as pd 
from pandas import Series, DataFrame
'''
更多Python学习资料以及源码教程资料,可以在群821460695 免费获取
'''
url = 'https://restapi.amap.com/v3/place/text'  # 搜索API
params = {'key':'你的高德密钥',  
          'types':'071400',     # 洗浴推拿场所
          'city':'320681'}      # 身份证前6位,以启东市为例    
res = requests.get(url,params)
jd = json.loads(res.text)       # 将JSON格式转化为Python字典格式
df1 = DataFrame(jd['pois'])     # 根据键取值,并放入数据框
df2 = df1[['address','adname','name','tel']]  # 只显示重要的几列
df2.head()    # 篇幅有限,只显示前5行

Here Insert Picture Description
Integration as a function of
the individual crawling above the city as a function of the integration process, so that only place you can get local data encoded in the city of Bath and Massage placed position of the argument.

def bath(city):
    url = 'https://restapi.amap.com/v3/place/text'
    params = {'key':'你的高德密钥',  
              'types':'071400',     # 洗浴推拿场所
              'city': city}         # 自变量,城市编码  
    res = requests.get(url,params)
    jd = json.loads(res.text)      # 将JSON格式转化为Python字典格式
    df = DataFrame(jd['pois'])     # 根据键取值,并放入数据框
    return df[['address','adname','name','tel']]  # 只显示重要的列

District of Baoding Xu water Hebei Province, which is encoded as an argument on behalf of the city into the function.

bath('130609').head()    # 以徐水区为例,只显示前5条记录

Here Insert Picture Description
Now, you know where to go take a bath yet?

Guess you like

Origin blog.csdn.net/fei347795790/article/details/102701451