fixt
This commit is contained in:
1 parent
2c832f4e0a
commit
c0a1bb1517
1 file changed
+10
-3
+10
-3
@@ -29,8 +29,6 @@ class htmlUtils:
|
|||||||
try:
|
try:
|
||||||
print("请求地址:",curl)
|
print("请求地址:",curl)
|
||||||
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":
|
|
||||||
url_text = res.json()
|
|
||||||
if type == "bytes":
|
if type == "bytes":
|
||||||
url_text = res
|
url_text = res
|
||||||
else:
|
else:
|
||||||
@@ -55,7 +53,16 @@ class htmlUtils:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getJSON(cls,curl):
|
def getJSON(cls,curl):
|
||||||
return cls.getHTML(curl,type="json")
|
count = 1
|
||||||
|
data_json = None
|
||||||
|
while count < 5:
|
||||||
|
try:
|
||||||
|
res = requests.get(curl, headers=cls.headers,timeout=30)
|
||||||
|
data_json = res.json()
|
||||||
|
except:
|
||||||
|
count += 1
|
||||||
|
cls.getJSON(curl)
|
||||||
|
return data_json
|
||||||
|
|
||||||
@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