bs4 cleanup

This commit is contained in:
2025-03-09 08:42:25 +11:00
parent 79b4a3eeb5
commit 2d5d5db1e6

View File

@@ -52,13 +52,13 @@ def pixelget(url: str):
def dayuploads_get(url: str): def dayuploads_get(url: str):
request = requests.get(url) request = requests.get(url)
soup = BeautifulSoup(request.content, 'html.parser') soup = BeautifulSoup(request.content, 'html.parser')
title = str(list(soup.find_all('p', class_="mb-0 text-ellipsis"))[0]).split(">")[1].split('<')[0] title = soup.find_all('p', class_="mb-0 text-ellipsis")[0].text
try: try:
assert ".torrent" in title.lower() assert ".torrent" in title.lower()
except AssertionError: except AssertionError:
logger.warning("Link was not a torrent") print("Link was not a torrent")
else: else:
download_url = str(list(soup.find_all('a', class_="download-link"))[0]).split('href="')[1].split('"')[0] download_url = soup.find_all('a', class_="download-link")[0]["href"]
torrent_file = requests.get(download_url) torrent_file = requests.get(download_url)
with open(title, "wb") as file: with open(title, "wb") as file:
file.write(torrent_file.content) file.write(torrent_file.content)