Python+pyecharts:全国猪价地图的实现
继续来说猪的事情,这次我们实现爬取全国各省份生猪价格,并用pyecharts画出全国生猪价格分布图。 爬取的网站为: 具体爬虫代码为: import pandas as pd import requests import json url = ' https://zhujia.zhuwang.cc/api/getMapJson?id=-1 ' headers = { ' User-Agent ' : ' Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36 ' } response = requests.get(url,headers= headers) json_text = response.json() data =json_text[ ' features ' ] lis = [] for i in range(0,32 ): # print(data[i]['properties']) try : lis.append([data[i][ ' properties ' ][ ' name ' ],data[i][ ' properties ' ][ ' pigprice ' ]]) except