栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

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

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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

首先开始展示最终效果:

数据来源——知网

数据格式展示如下:

目标:根据高校名称,查找经纬度,并用地图展示,保存成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('nametlongn')
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/

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/870995.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号