27 lines
959 B
Python
27 lines
959 B
Python
import requests as r
|
|
import os
|
|
import shutil
|
|
import zipfile
|
|
|
|
res = r.get('https://kirigaya.cn/files/links/tmp.zip')
|
|
|
|
# 解压文件
|
|
with zipfile.ZipFile('./scripts/tmp.zip', 'r') as zipf:
|
|
zipf.extractall('./scripts/tmp')
|
|
|
|
# 将文件搬运至工作区,我的 css 全放在 public 下面了,你的视情况而定
|
|
for parent, _, files in os.walk('./scripts/tmp'):
|
|
for file in files:
|
|
filepath = os.path.join(parent, file)
|
|
if file.startswith('demo'):
|
|
continue
|
|
if file.endswith('.css'):
|
|
content = open(filepath, 'r', encoding='utf-8').read().replace('font-size: 16px;', '')
|
|
open(filepath, 'w', encoding='utf-8').write(content)
|
|
shutil.move(filepath, os.path.join('./public', file))
|
|
elif file.endswith('.woff2'):
|
|
shutil.move(filepath, os.path.join('./public', file))
|
|
|
|
# 删除压缩包和解压区域
|
|
os.remove('./scripts/tmp.zip')
|
|
shutil.rmtree('./scripts/tmp') |