From 6d56abbb28f92589c6d6fee801b3ede7c69e2232 Mon Sep 17 00:00:00 2001 From: gfdgd_xi <3025613752@qq.com> Date: Mon, 5 May 2025 16:04:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DMono/Gecko=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E5=99=A8=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?Mono/Gecko=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- InstallMono.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/InstallMono.py b/InstallMono.py index 98462c5..a56b307 100755 --- a/InstallMono.py +++ b/InstallMono.py @@ -12,6 +12,7 @@ ################# import os import sys +import requests import updatekiller import traceback try: @@ -56,10 +57,16 @@ try: exitInputShow = int(os.getenv("ENTERNOTSHOW")) except: exitInputShow = True + +headers = { + 'User-Agent': "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/130.0.0.0" +} try: # 获取最新版本的版本号 - programVersionList = pyquery.PyQuery(url=f"http://mirrors.ustc.edu.cn/wine/wine/wine-{sys.argv[3]}/") + data = requests.get(f"http://mirrors.ustc.edu.cn/wine/wine/wine-{sys.argv[3]}/", headers=headers) + programVersionList = pyquery.PyQuery(data.text) except: + traceback.print_exc() print("无法连接下载服务器,将使用本地缓存") if not os.path.exists(f"{homePath}/.cache/deepin-wine-runner/{sys.argv[3]}/install.msi") or not os.path.exists(f"{homePath}/.cache/deepin-wine-runner/{sys.argv[3]}/information.txt"): print("无本地缓存数据,无法进行、结束") @@ -75,7 +82,8 @@ except: exit() programVersion = programVersionList("a:last-child").attr.href # 获取最新版本安装包的URL -programUrl = pyquery.PyQuery(url=f"http://mirrors.ustc.edu.cn/wine/wine/wine-{sys.argv[3]}/{programVersion}") +data = requests.get(f"http://mirrors.ustc.edu.cn/wine/wine/wine-{sys.argv[3]}/{programVersion}", headers=headers) +programUrl = pyquery.PyQuery(data.text) programDownloadUrl = "" programFileName = "" for i in programUrl("a").items():