Improved contact scraping using Selenium#1
Open
eugenrmain wants to merge 2 commits intoFraneCal:mainfrom
Open
Conversation
…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
FraneCal
reviewed
Mar 28, 2025
| print("Accepted cookies.") | ||
| except NoSuchElementException: | ||
| print("No accept cookies button found.") | ||
| except Exception: |
Owner
There was a problem hiding this comment.
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 |
Owner
There was a problem hiding this comment.
I find WebDriverWait to be better because I doesn't always have to wait for the whole time (in this case yours 5 sec).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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