50 lines
1.8 KiB
Python
50 lines
1.8 KiB
Python
import requests
|
|
import json
|
|
import xlwings as xw
|
|
from pprint import pprint
|
|
import pandas as pd
|
|
|
|
def getMap(url,params,headers,path):
|
|
response = requests.get(url=url,headers=headers,params=params)
|
|
results = json.loads(response.content)
|
|
data = results['data']
|
|
name = []
|
|
amount = []
|
|
upstream = []
|
|
percent = []
|
|
Type = []
|
|
for item in data:
|
|
if (item['name']==None) or (item['amount'] + item['upstream'] + item['percent'] <= 0.00001):
|
|
continue
|
|
name.append(item['name'])
|
|
amount.append(item['amount']) # 当前过程的碳排放
|
|
upstream.append(item['upstream']) # 当前过程加上上游的碳排放
|
|
percent.append(item['percent']) # 影响百分比
|
|
Type.append(item['type']) # 所述的过程类型
|
|
|
|
df = pd.DataFrame({"name":name,"amount":amount,"upstream":upstream,"percent":percent,"type":Type})
|
|
path = f"/home/zhangxj/WorkFile/LCA-GPT/DataAnalysis/lciaData/{path}.csv"
|
|
df.to_csv(path,index=False)
|
|
return df
|
|
|
|
if __name__ == '__main__':
|
|
|
|
# map数据的url
|
|
url = 'https://lca.qibebt.ac.cn/lca/analysis/lcia/map?taskId=1280544753347198976&categoryId=44645932&t=1725347326992'
|
|
params = {
|
|
'taskId':'1268567356305571840',
|
|
'categoryId': '43260647',
|
|
't': '1722491855892'
|
|
}
|
|
headers = {
|
|
'accept':'application/json, text/plain, */*',
|
|
'accept-encoding':'gzip, deflate, br, zstd',
|
|
'accept-language':'zh-CN',
|
|
'authorization':'Bearer d88024bb-6434-4adf-91fb-52dff44261c3',
|
|
'priority':'u=1, i',
|
|
'referer':'https://lca.qibebt.ac.cn/',
|
|
'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36'
|
|
}
|
|
name = "风力发电机"
|
|
getMap(url,params,headers,name)
|