fix
This commit is contained in:
1 parent
45ac0732fd
commit
1473014aca
1 file changed
+13
-5
+13
-5
@@ -29,11 +29,9 @@ class htmlUtils:
|
|||||||
if count <= 10:
|
if count <= 10:
|
||||||
try:
|
try:
|
||||||
print(f"请求地址:{curl}")
|
print(f"请求地址:{curl}")
|
||||||
res = s.get(curl,stream=True, headers=cls.headers, timeout=50)
|
res = s.get(curl,stream=True, headers=cls.headers, timeout=180)
|
||||||
if type == "bytes":
|
if type == "bytes":
|
||||||
return res
|
url_text = res
|
||||||
if type == "json":
|
|
||||||
return res.json()
|
|
||||||
else:
|
else:
|
||||||
url_text = html.fromstring(res.text)
|
url_text = html.fromstring(res.text)
|
||||||
except:
|
except:
|
||||||
@@ -56,7 +54,17 @@ class htmlUtils:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getJSON(cls,curl):
|
def getJSON(cls,curl):
|
||||||
cls.getHTML(curl, type="json")
|
count = 0
|
||||||
|
while count < 5:
|
||||||
|
try:
|
||||||
|
res = requests.get(curl, headers=cls.headers, timeout=180)
|
||||||
|
data_json = res.json()
|
||||||
|
return data_json
|
||||||
|
except:
|
||||||
|
ntfy.sendMsg(f"请求失败,重试中... {curl}")
|
||||||
|
count += 1
|
||||||
|
time.sleep(1)
|
||||||
|
cls.getJSON(curl)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def xpathData(cls,c_xpath,url=None,num=None,not_eq=None):
|
def xpathData(cls,c_xpath,url=None,num=None,not_eq=None):
|
||||||
|
|||||||
Reference in new issue
Block a user