From 2d5d5db1e6a3b50eecc17932cb4a39c69d55f9bf Mon Sep 17 00:00:00 2001 From: Mihit Date: Sun, 9 Mar 2025 08:42:25 +1100 Subject: [PATCH] bs4 cleanup --- DiscordBot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DiscordBot.py b/DiscordBot.py index f2af4d7..174ac5a 100644 --- a/DiscordBot.py +++ b/DiscordBot.py @@ -52,13 +52,13 @@ def pixelget(url: str): def dayuploads_get(url: str): request = requests.get(url) 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: assert ".torrent" in title.lower() except AssertionError: - logger.warning("Link was not a torrent") + print("Link was not a torrent") 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) with open(title, "wb") as file: file.write(torrent_file.content)