modify scripts

This commit is contained in:
oscarz
2025-04-23 19:18:06 +08:00
parent e73250ffd0
commit 16fe4ec54e
2 changed files with 63 additions and 2 deletions
+10
View File
@@ -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)