My niece asked me to create a way to send a lot of messages in WhatsApp to her friend in her birthday. So I made this script using Python 3 and Selenium to automate this process and send more messages possible would be a manual way.
- Python3
- Pip3
- Selenium
- Firefox
- Firefox Webdriver for Selenium
pip3 install Selenium
sudo apt-get install firefox
- Step 1: Go to the Geckodriver releases page. Find the latest version of the driver for your platform and download it. The version used was v.0.26.0:
wget https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz
- Step 2: Extract the file with:
tar -xvzf geckodriver*
- Step 3: Make it executable:
chmod +x geckodriver
- Step 4: Move the executable file for usr/local/bin:
sudo mv geckodriver /usr/local/bin/
- enter_name_element: The element in HTML area where enter the contact or group name to select
- send_message_element: The element in HTML area where the Bot will typed the messages and send
Both can change over time, so if you accuse NoSuchElementException, go to Web Developer and find the class related to these variables.
- delay: The time between sending two messages
Take care with the time, if you set a small one, WhatsApp can block your account.
There is a archive named messages.py, put all the messages you want to send in the list named msgList.
The bot will send messages at random.
- Step 1: Run main.py:
python3 main.py
-
Step 2: Print in console, how many messages do you want to send and the name of the contact or the group
-
Step 3: Log in in Web WhatsApp with the QR Code. Everytime you run, you have to log in again.
-
Step 4: Press Enter in terminal.