Skip to content

Conversation

@eugenrmain
Copy link

Improved the scraping of contacts by removing the reliance of BeatifulSoup and using Selenium instead for actually clicking the services, thus excerting the contact information properly. Also added the latest imports in requirements.txt

…lSoup and using Selenium instead for actually clicking the services, thus excerting the contact information properly. Also added the latest imports in requirements.txt
…lSoup and using Selenium instead for actually clicking the services, thus excerting the contact information properly. Also added the latest imports in requirements.txt
print("Accepted cookies.")
except NoSuchElementException:
print("No accept cookies button found.")
except Exception:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why catch all errors if you only need two ones: when there is no button to click (NoSuchElementException) and when time runs out which could be added (TimeoutException)?

# Wait for the sidebar to load
print("Waiting for the sidebar to load...")
divSideBar = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, f"div[aria-label*='{service.lower()} {location.lower()}']")))
# Wait for results to load
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find WebDriverWait to be better because I doesn't always have to wait for the whole time (in this case yours 5 sec).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants