From 1cc617aedaf258330e64b1b117806e9ce8cf4808 Mon Sep 17 00:00:00 2001 From: Tomuxs Date: Sat, 2 Aug 2025 23:23:21 +0200 Subject: [PATCH] Check for invalid posts --- py34/list.py | 9 ++++++++- py34/scraper.py | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/py34/list.py b/py34/list.py index 1e7d269..8bc44b7 100644 --- a/py34/list.py +++ b/py34/list.py @@ -31,6 +31,13 @@ class List: if str(entry).strip() == "": continue if entry.name != "span": continue + # Get ID + post_id = int(entry["id"][1:]) + + # Rule34 displays invalid posts when near 1 + if post_id < 1: + continue + # Extract image img = entry.find_all("img")[0] if "src" in img.attrs: @@ -40,7 +47,7 @@ class List: # Append post self.posts.append(Post( - int(entry["id"][1:]), + post_id, img_src.dir, img_src.id, img["alt"].split(" "), diff --git a/py34/scraper.py b/py34/scraper.py index 776bd05..01bcf06 100644 --- a/py34/scraper.py +++ b/py34/scraper.py @@ -7,7 +7,7 @@ from bs4 import BeautifulSoup class ScraperException(Exception): def __init__(self, res: Response, *argv: any): - super(*argv) + super(Exception, *argv) self.response = res