JAVA日报
2021/6/21 11:28:03
本文主要是介绍JAVA日报,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
双人结对作业疫情可视化(地图json爬虫)
#!/usr/bin/python # -*- coding: UTF-8 -*- import json import requests import xlrd import xlwt # 获取所有数据json文件 def download_Json(url, name): print("-----------正在下载json文件 %s" % (url)) print(name) try: # 将响应信息进行json格式化 response = requests.get(url) versionInfo = response.text # versionInfo Unicode类型 # print(versionInfo) # print(type(versionInfo)) versionInfoPython = json.loads(versionInfo) # unicode转化为字典类型 # print(type(versionInfoPython)) # print(versionInfoPython) path = "E:\\Pycharm\\Project\\geojson\\" +name + ".json" # 修改一下路径 print(path) # 将json格式化的数据保存 with open(path, 'w') as f1: f1.write(json.dumps(versionInfoPython, indent=4)) # json.dumps()将字典转化为json indent=4是为了好看 print("下载成功,文件保存位置:" + path) except Exception as ex: print("--------下载出错----") pass # 获取对应数据的json文件 for i in range(35): workbook = xlrd.open_workbook(r'E:\Pycharm\Project\geojson\CITYCODE.xls') # 修改一下路径 sheet1 = workbook.sheet_by_name('Sheet1') nrows = sheet1.nrows ncols = sheet1.ncols # print(nrows,ncols) cell_A = sheet1.cell(i, 0).value cell_B = int(sheet1.cell(i, 1).value) #print(cell_B) #print(cell_A) url = 'https://geo.datav.aliyun.com/areas_v2/bound/' + str(cell_B) + '_full.json' # 输入json地址 download_Json(url, cell_A) # 第一个参数是json文件的地址,第二个参数是文件保存的名称, print(i + 1) a = i + 1
这篇关于JAVA日报的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-26结对编程到底难不难?答案在这里
- 2024-06-19《2023版Java工程师》课程升级公告
- 2024-06-15matplotlib作图不显示3D图,怎么办?
- 2024-06-1503-Loki 日志监控
- 2024-06-1504-让LLM理解知识 -Prompt
- 2024-06-05做软件测试需要懂代码吗?
- 2024-06-0514-ShardingSphere的分布式主键实现
- 2024-06-03为什么以及如何要进行架构设计权衡?
- 2024-05-31全网首发第二弹!软考2024年5月《软件设计师》真题+解析+答案!(11-20题)
- 2024-05-31全网首发!软考2024年5月《软件设计师》真题+解析+答案!(21-30题)