forked from qxmao/chromego_merge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sb.py
27 lines (21 loc) · 918 Bytes
/
sb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import requests
import os
url = "https://sing-box-subscribe-doraemon.vercel.app/config/https://raw.githubusercontent.com/QiChaiQiChai/ChromeGo/main/sub/base64.txt&file=https://raw.githubusercontent.com/QiChaiQiChai/sing-box-subscribe_configs/main/1.json"
output_folder = "sub"
output_filename = "sing-box.json"
# 发送HTTP请求
response = requests.get(url)
# 检查请求是否成功
if response.status_code == 200:
# 创建输出
# 确保输出文件夹存在
if not os.path.exists(output_folder):
os.makedirs(output_folder)
# 构建输出文件路径
output_path = os.path.join(output_folder, output_filename)
# 将响应内容写入文件,使用utf-8编码
with open(output_path, 'w', encoding='utf-8') as file:
file.write(response.text)
print(f"成功将内容写入 {output_path}")
else:
print(f"HTTP请求失败,状态码: {response.status_code}")