From 177098bcf82ff03861adcb2c6f9600faadd11501 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sat, 23 Dec 2023 12:51:31 -0500 Subject: [PATCH] Revert next renew button iteration change (#22) --- craigslist-renew.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/craigslist-renew.py b/craigslist-renew.py index 25e66dd..7d64aba 100755 --- a/craigslist-renew.py +++ b/craigslist-renew.py @@ -64,9 +64,11 @@ def check_expired(): def renew_posts(): # loop thru up to 5 pages for page in range(1, 6): - # loop thru renew buttons - for button in driver.find_elements(By.XPATH, '//input[@type="submit" and @value="renew"]'): + # look for all listings with a renew button + while True: try: + # find next renew button element + button = driver.find_element(By.XPATH, '//input[@type="submit" and @value="renew"]') # fetch posting link form_action = button.find_element(By.XPATH, '..').get_attribute('action') post_id = form_action.split('/')[-1] @@ -91,7 +93,7 @@ def renew_posts(): driver.refresh() except NoSuchElementException: - continue + break # go to next page if link found try: