Files
zlib-dl/parse_dl.py
T
2026-03-31 18:18:35 +08:00

19 lines
634 B
Python

from zlib_dl import ZLibSession
import re
from bs4 import BeautifulSoup
s = ZLibSession(verbose=True)
url = "https://zlib.li/book/mDJxkg7yO6/%E6%B5%AA%E6%BD%AE%E4%B9%8B%E5%B7%85%E7%AC%AC%E5%9B%9B%E7%89%88.html"
resp = s._request_download(url)
soup = BeautifulSoup(resp.text, 'html.parser')
a_tag = soup.find('a', href=re.compile(r"^/dl/\w+"))
if a_tag:
print(f"FOUND: {a_tag['href']}")
else:
print("NOT FOUND")
# let's try another heuristic
dl_btn = soup.find('a', class_=re.compile(r"addDownloadedBook"))
if dl_btn:
print("FOUND VIA CLASS:", dl_btn.get("href"))
else:
print("STILL NOT FOUND")