This project includes several Python scripts to scrape contacts and chat messages from WhatsApp Web using Selenium.
- Python: Make sure you have Python 3.6 or higher installed.
- Google Chrome: Ensure you have Google Chrome installed.
- ChromeDriver: Download ChromeDriver from the official website: ChromeDriver
-
Clone the repository:
git clone https://github.com/LahcenEzzara/WhatsApp-Scraping-Python.git
-
Install the required packages:
pip install -r requirements.txt
-
Set up the ChromeDriver:
- Download the ChromeDriver from the link ChromeDriver.
- Extract the downloaded file.
- Note the path where you extracted the
chromedriver
executable.
- Script:
contacts_scraper.py
- Description: Scrapes contact numbers from WhatsApp Web.
- Configuration: Update the
chrome_user_data_dir
andchrome_driver_path
variables in the script with your own paths. - Run:
py contacts_scraper.py
- Script:
single_chat_scraper.py
- Description: Scrapes messages from a specific WhatsApp chat.
- Configuration: Update the
chrome_user_data_dir
andchrome_driver_path
variables in the script with your own paths. Edit the script to set thechat_name
variable to the name of the chat you want to scrape. - Run:
py single_chat_scraper.py
- Script:
csv_multi_chat_scraper.py
- Description: Scrapes messages from multiple WhatsApp chats listed in a CSV file.
- Configuration: Update the
chrome_user_data_dir
andchrome_driver_path
variables in the script with your own paths. Ensure you have acontact_numbers.csv
file with chat names, one per line. - Run:
py csv_multi_chat_scraper.py
- Script:
multi_chat_scraper.py
- Description: Scrapes messages from multiple WhatsApp chats specified in the script.
- Configuration: Update the
chrome_user_data_dir
andchrome_driver_path
variables in the script with your own paths. Edit the script to update thechat_names
list with the names of the chats you want to scrape. - Run:
py multi_chat_scraper.py
- Ensure that you have logged into WhatsApp Web on Chrome before running the scripts.
- The scripts will prompt you to scan the QR code if you are not logged in.
This project is licensed under the MIT License. See the LICENSE file for details.