sfun commited on
Commit
d42b0aa
1 Parent(s): 1cbfbf7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -48,14 +48,17 @@ async def fetch_url(url, session, max_retries=5):
48
  async def extract_and_transform_proxies(input_text):
49
  try:
50
  data = yaml.safe_load(input_text)
51
-
52
- # 只处理 'proxies' 部分,忽略其他部分
53
  if isinstance(data, dict) and 'proxies' in data:
54
  proxies_list = data['proxies']
55
  elif isinstance(data, list):
56
  proxies_list = data
57
  else:
58
- return "未找到有效的代理配置"
 
 
 
 
 
59
  except yaml.YAMLError:
60
  return "YAML解析错误"
61
 
 
48
  async def extract_and_transform_proxies(input_text):
49
  try:
50
  data = yaml.safe_load(input_text)
 
 
51
  if isinstance(data, dict) and 'proxies' in data:
52
  proxies_list = data['proxies']
53
  elif isinstance(data, list):
54
  proxies_list = data
55
  else:
56
+ proxies_match = re.search(r'proxies:\s*\n((?:[-\s]*{.*\n?)*)', input_text, re.MULTILINE)
57
+ if proxies_match:
58
+ proxies_text = proxies_match.group(1)
59
+ proxies_list = yaml.safe_load(proxies_text)
60
+ else:
61
+ return "未找到有效的代理配置"
62
  except yaml.YAMLError:
63
  return "YAML解析错误"
64