fix: 增加重试机制

This commit is contained in:
chenwj113 2023-07-09 22:19:02 +08:00
parent 2d77f3ff51
commit bd5580ee4b
1 changed files with 8 additions and 3 deletions

View File

@ -1,5 +1,5 @@
import time
from retrying import retry
from schedule import every, repeat, run_pending
from requests_html import HTML, HTMLSession
@ -8,11 +8,16 @@ from lottery import Lottery
session = HTMLSession()
def get_data_job(lottery_type='pls'):
@retry(stop_max_attempt_number=5)
def get_data_job(lottery_type='pls', issue=None):
"""
:param lottery_type
"""
if issue is None:
url = f"https://kaijiang.500.com/{lottery_type}.shtml"
else:
url = f"http://kaijiang.500.com/shtml/{lottery_type}/{issue}.shtml"
r = session.get(url)
if lottery_type == 'pls':
issue_elem = r.html.search('排列3 第 {}')