From e733779737502211eaf7df5cbf19d993da99037d Mon Sep 17 00:00:00 2001 From: retrozelda Date: Sun, 9 Feb 2025 00:52:48 -0500 Subject: [PATCH] able to fetch content in a series with page limits --- beacon_snatch/series.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/beacon_snatch/series.py b/beacon_snatch/series.py index de95a01..bf6dd36 100644 --- a/beacon_snatch/series.py +++ b/beacon_snatch/series.py @@ -103,7 +103,7 @@ class BeaconSeries: return new_series # fetches all the content for this series - def fetch(self, auth : BeaconAuthentication): + def fetch(self, auth : BeaconAuthentication, max_pages = -1): driver = auth.get_driver() driver.get(self.series_url) @@ -119,8 +119,12 @@ class BeaconSeries: logging.log(helpers.LOG_VERBOSE, f"\"Load More\" click #{click_count}") click_count = click_count + 1 - load_more_button.click() - time.sleep(1) + + if max_pages < 0 or click_count < max_pages: + load_more_button.click() + time.sleep(1) + else: + break except ElementClickInterceptedException: # clicking too fast or while its loading will throw this, so we will just try again continue except NoSuchElementException: # I hate python