添加无锡锡山人民医院票据处理

This commit is contained in:
2024-09-06 12:43:31 +08:00
parent 0b4ccd9b84
commit c2717c29b7
3 changed files with 63 additions and 28 deletions

View File

@@ -41,3 +41,18 @@ def download_pdf(url, local_filename=None):
if chunk: # filter out keep-alive new chunks
file.write(chunk)
return local_filename
@retry(stop=stop_after_attempt(3), wait=wait_random(1, 3), reraise=True,
after=lambda x: logging.warning('获取无锡锡山人民医院票据失败!'))
def get_wxxsh_pdf_url(url):
response = requests.get(url)
if response.status_code != 200:
raise Exception(f'请求无锡锡山人民医院票据失败!状态码: {response.status_code}')
soup = BeautifulSoup(response.text, 'html.parser')
pdf_url = soup.find('a', string='点击查看电子票据')
if pdf_url:
# 获取隐藏字段的值
value = pdf_url.get('href')
return value
return None