fix
This commit is contained in:
parent
ebb49ce04c
commit
378dd2829b
@ -31,6 +31,8 @@ class htmlUtils:
|
|||||||
res = s.get(curl,stream=True, headers=cls.headers, timeout=20)
|
res = s.get(curl,stream=True, headers=cls.headers, timeout=20)
|
||||||
if type == "json":
|
if type == "json":
|
||||||
url_text = res.json()
|
url_text = res.json()
|
||||||
|
if type == "bytes":
|
||||||
|
url_text = res
|
||||||
else:
|
else:
|
||||||
url_text = html.fromstring(res.text)
|
url_text = html.fromstring(res.text)
|
||||||
except:
|
except:
|
||||||
@ -42,10 +44,15 @@ class htmlUtils:
|
|||||||
else:
|
else:
|
||||||
print(f"fail 请求失败:{curl}")
|
print(f"fail 请求失败:{curl}")
|
||||||
break
|
break
|
||||||
data = { curl : url_text}
|
if not type == "bytes":
|
||||||
cls.url_data.update(data)
|
data = { curl : url_text}
|
||||||
|
cls.url_data.update(data)
|
||||||
return url_text
|
return url_text
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def getBytes(cls, url):
|
||||||
|
return cls.getHTML(url,type="bytes")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getJSON(cls,curl):
|
def getJSON(cls,curl):
|
||||||
return cls.getHTML(curl,type="json")
|
return cls.getHTML(curl,type="json")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user