From 378dd2829bce312c1326012b45be7123cc791bae Mon Sep 17 00:00:00 2001 From: caiwx86 Date: Thu, 8 Dec 2022 07:31:30 +0800 Subject: [PATCH] fix --- utils/HtmlUtils.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/utils/HtmlUtils.py b/utils/HtmlUtils.py index 5d3b06b..0d70cf1 100644 --- a/utils/HtmlUtils.py +++ b/utils/HtmlUtils.py @@ -31,6 +31,8 @@ class htmlUtils: res = s.get(curl,stream=True, headers=cls.headers, timeout=20) if type == "json": url_text = res.json() + if type == "bytes": + url_text = res else: url_text = html.fromstring(res.text) except: @@ -42,10 +44,15 @@ class htmlUtils: else: print(f"fail 请求失败:{curl}") break - data = { curl : url_text} - cls.url_data.update(data) + if not type == "bytes": + data = { curl : url_text} + cls.url_data.update(data) return url_text + @classmethod + def getBytes(cls, url): + return cls.getHTML(url,type="bytes") + @classmethod def getJSON(cls,curl): return cls.getHTML(curl,type="json")