From 3c6380cb82b9cdfc351c7edca20ce504b08b125d Mon Sep 17 00:00:00 2001 From: snowykami Date: Tue, 17 Sep 2024 14:55:05 +0800 Subject: [PATCH] =?UTF-8?q?:package:=20docs:=20=E8=B5=84=E6=BA=90=E5=95=86?= =?UTF-8?q?=E5=BA=97=E6=96=B0=E5=A2=9E=E5=8F=91=E5=B8=83=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- liteyuki_flow/resource_handler.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/liteyuki_flow/resource_handler.py b/liteyuki_flow/resource_handler.py index ffa48b8a..a7f454e2 100644 --- a/liteyuki_flow/resource_handler.py +++ b/liteyuki_flow/resource_handler.py @@ -14,6 +14,11 @@ from liteyuki_flow.const import OPENED, EDITED, CLOSED, REOPENED, RESOURCE_JSON from liteyuki_flow.markdown_parser import MarkdownParser from liteyuki_flow.typ import err, nil +user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3" + +headers = { + "User-Agent": user_agent +} # opened: 创建新的资源包,预审核 # edited: 编辑资源包信息,需重新审核 @@ -34,8 +39,7 @@ def pre_check(github: Github, issue: Issue, repo: Repository) -> err: return ValueError("name, desc, link, homepage 及 author 为必填字段.") # 下载并解析资源包 - r = requests.get(link) - print(r.status_code) + r = requests.get(link, headers=headers) if r.status_code != 200: issue.create_comment("下载失败.") return ValueError("下载失败.")