增加重试逻辑
This commit is contained in:
parent
2db825b352
commit
8ae878587b
14
qushuiyin.py
14
qushuiyin.py
|
@ -16,10 +16,19 @@ def endecode_and_proxy_url(original_url):
|
|||
class Video:
|
||||
def douyin(self, url):
|
||||
# Extract ID from URL
|
||||
id_match = self.extract_id(url)
|
||||
if not id_match:
|
||||
for attempt_1 in range(10):
|
||||
id_match = self.extract_id(url)
|
||||
if id_match:
|
||||
break
|
||||
else:
|
||||
time.sleep(0.5)
|
||||
else:
|
||||
return {"code": 400, "msg": "Unable to parse video ID"}
|
||||
|
||||
# id_match = self.extract_id(url)
|
||||
# if not id_match:
|
||||
# return {"code": 400, "msg": "Unable to parse video ID"}
|
||||
|
||||
video_id = id_match
|
||||
|
||||
# Construct request headers
|
||||
|
@ -46,7 +55,6 @@ class Video:
|
|||
matches = re.search(pattern, response.text, re.DOTALL)
|
||||
|
||||
if matches:
|
||||
print(attempt)
|
||||
break
|
||||
else:
|
||||
time.sleep(0.5)
|
||||
|
|
Loading…
Reference in New Issue