modify scripts
This commit is contained in:
@@ -106,3 +106,13 @@ def remove_url_query(url: str) -> str:
|
||||
except Exception as e:
|
||||
print(f"解析 URL 失败: {e}")
|
||||
return url
|
||||
# 写csv文件
|
||||
def json_to_csv(data, output_file):
|
||||
if not data:
|
||||
return
|
||||
headers = list(data[0].keys())
|
||||
with open(f"{update_dir}/{output_file}", 'w', encoding='utf-8', newline='') as csvfile:
|
||||
writer = csv.DictWriter(csvfile, fieldnames=headers)
|
||||
writer.writeheader()
|
||||
for row in data:
|
||||
writer.writerow(row)
|
||||
|
||||
Reference in New Issue
Block a user