Pyecharts+高德地图实现3D地图效果
首先開始展示最終效果:
數據來源——知網
數據格式展示如下:
目標:根據高校名稱,查找經緯度,并用地圖展示,保存成html文件。
爬蟲準備
完整代碼如下:
import requests import re from bs4 import BeautifulSoup import pandas as pd import timeheaders = {"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 + 1time.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/
總結
以上是生活随笔為你收集整理的Pyecharts+高德地图实现3D地图效果的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Excel图表制作(二):滚动条实现动态
- 下一篇: Xshell脚本学习