diff --git a/waternsw_grabber/waternsw_grabber.py b/waternsw_grabber/waternsw_grabber.py index 96577be..10ce8dc 100644 --- a/waternsw_grabber/waternsw_grabber.py +++ b/waternsw_grabber/waternsw_grabber.py @@ -89,8 +89,10 @@ def get_telemetered_bore(driver, bore_id, start_date, end_date): time.sleep(0.5) # Detect if bore record does not exist - if body_text.startswith('No SITE record found for site'): + if 'No SITE record found for site' in body_text: raise ValueError('No SITE record found for site {}'.format(bore_id)) + elif 'No variables data found for this site.' in body_text: + raise ValueError('No variables data found for site {}'.format(bore_id)) # Wait for navigation tabs wait_for_element(driver, By.XPATH, '//*[@id="tabstext"]') @@ -212,8 +214,8 @@ def telemetered_bore_downloader(bore_ids, start_date, end_date, download_dir): pbar.set_description(bore_id) try: get_telemetered_bore(driver, bore_id, start_date, end_date) - except ValueError: - logging.error('Failed to download {}\n'.format(bore_id)) + except ValueError as e: + logging.error(e) # Tidy up console after tqdm print('\n')