This project is a web scraping tool designed to extract real estate agent profiles (both individual brokers and teams) from the Corcoran real estate website. The script uses Selenium and BeautifulSoup to automate browser interactions and parse the HTML to collect broker information, saving it into an Excel file.
- Scrapes individual brokers and teams.
- Handles automatic pagination until all brokers are scraped.
- Extracts broker names, emails, and phone numbers.
- Cleans and formats phone numbers for consistency.
- Saves data in an Excel file (
clean_brokers_data.xlsx).
- Python 3.10+
- Selenium for browser automation.
- BeautifulSoup for HTML parsing.
- Pandas for data manipulation and Excel output.
- Microsoft Edge WebDriver (ensure it's compatible with your browser version).
- Microsoft Edge (or modify to use another browser).
- Edge WebDriver.
- Python and the following libraries:
seleniumbs4(BeautifulSoup)pandasopenpyxl
Install the dependencies using:
pip install -r requirements.txt-
Clone the repository:
git clone https://github.com/azafoura/NY-Scraper.git cd NY-Scraper -
Download and set up Edge WebDriver:
- Download the WebDriver from here.
- Place
msedgedriver.exein the project folder or ensure it's in your system path.
-
Run the scraper:
python Broker_scraper.py
-
Check the Excel output:
- The scraped data will be saved in
clean_brokers_data.xlsx.
- The scraped data will be saved in
- Broker Information: Scrapes the broker's name, email, and phone number.
- Team Handling: Detects team profiles and scrapes individual team members.
- Pagination: Automatically clicks the next button until no more pages remain.
- Phone Formatting: Cleans phone numbers to ensure they are in a standardized format (removes country code if unnecessary).
To scrape brokers from regions other than New York City, follow these steps:
-
Search for the desired region by entering the city or area in the search bar.
-
Once the search results are displayed, copy the URL from the address bar.
-
Update the
base_urlvariable in the script with the copied link:base_url = '<copied-link>'
- The final output is an Excel file,
clean_brokers_data.xlsx, which contains cleaned and de-duplicated broker data.
Ensure that msedgedriver.exe is included in the project.
This project is licensed under the MIT License. See the LICENSE file for details.