This commit is contained in:
caiwx86 2022-12-08 07:31:30 +08:00
parent ebb49ce04c
commit 378dd2829b

View File

@ -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")