Pyecharts+高德地图实现3D地图效果

Pyecharts+高德地图实现3D地图效果,第1张

首先开始展示最终效果:

数据来源——知网

数据格式展示如下:

目标:根据高校名称,查找经纬度,并用地图展示,保存成html文件。

爬虫准备

完整代码如下:

import requests
import re
from bs4 import BeautifulSoup
import pandas as pd
import time

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36"
}

l1_name = []


def get_location(location):
    gaode_api_url = "https://restapi.amap.com/v3/geocode/geo?address=" + str(
        location) + "&output=XML&key=5ffb29f6dfb07ce65ff4fd7424798a85"
    response = requests.get(gaode_api_url, headers=headers)
    Soup = BeautifulSoup(response.content, 'lxml')
    l1 = Soup.find('location')
    if Soup.location == None:
        print("查询点:{0},坐标为:{1}".format(str(location), 0))
    else:
        print("查询点:{0},坐标为:{1}".format(str(location), l1.text))
    if Soup.location == None:
        l1_name.append([str(location), 0])
    else:
        l1_name.append([str(location), l1.text])



path = 'sch2.xlsx'
location_data = pd.DataFrame(pd.read_excel(path))
location_name = location_data['location']

n = 1
print('----------------开始查询---------------')
for i in range(len(location_name)):
    print('{0}:'.format(n))
    get_location(location_name[i])
    n = n + 1
    time.sleep(0.1)
print('----------------查询结束---------------')

result = open('sch3.xls', 'w', encoding='gbk')
result.write('name\tlong\n')
for m in range(len(l1_name)):
    for n in range(len(l1_name[m])):
        result.write(str(l1_name[m][n]))
        result.write('\t')
    result.write('\n')
result.close()
高德地图分享html

文章参考

【1】https://blog.csdn.net/qq_42902997/article/details/108293007?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165208920416781432928080%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=165208920416781432928080&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allfirst_rank_ecpm_v1~rank_v31_ecpm-3-108293007-null-null.142v9pc_search_result_cache,157v4control&utm_term=%E8%AF%BB%E5%8F%96%E7%BB%8F%E7%BA%AC%E5%BA%A6%E7%BB%98%E5%88%B6%E5%9C%B0%E5%9B%BEpyecharts&spm=1018.2226.3001.4187
【2】https://www.freesion.com/article/74441069093/

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/885396.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-14
下一篇2022-05-14

发表评论

登录后才能评论

评论列表(0条)

    保存