Automatically send Whatsapp messages and files
Project description
What is Pyzapkit?
Do you waste countless hours sending messages though Whatsapp? Do you need to send the same file over and over again to different contacts? Say no more. Pyzapkit lets you automate all of your Whatsapp messages!
Using selenium and pyautogui, Pyzapkit lets you send text messages or files, instantly or at a certain time of the day
How to use it
First, install pyzapkit:
pip install pyzapkit
Import the Pyzap class:
from pyzapkit.main import Pyzap
Now, you need to check which Google Chrome profile has your whatsapp web account, to do this, go to:
On linux
/home/your_user/.config/google-chrome
On windows
C:\Users\your_user\AppData\Local\Google\Chrome\User Data
Inside those folders will be your chrome profiles. Usually, they will be named as 'Profile 1', 'Profile 2', 'Profile 3' and so on, but they can also be named as 'Default' or your chrome user name. Choose the one that has your whatsapp web account login.
Instantiate Pyzap with your Chrome profile as an argument:
whatsapp = Pyzap('Profile 2')
From there, you can:
Send text messages
whatsapp.send_message('123456789', 'a message')
To send text messages at a given time
whatsapp.send_message('123456789', 'a message', False, '14', '15')
- Use 24-hour format
- You can use an int or a str as the phone number
- It is not needed to start the phone number with the plus (+) sign
A Chrome browser will be opened and the message will be sent.
Send images or videos
whatsapp.send_file('123456789', 'path/to/your/file.png')
- You can send both images (jpg, jpeg or png) or videos (mp4).
You can also send a file at a certain time.
whatsapp.send_file('123456789', 'path/to/your/file.png', instantly=False, hour='14', min='15')
You can also specify how long the browser will wait for the file to upload
whatsapp.send_file('123456789', 'path/to/your/file.png', '5', False, '14', '15')
When using this method, a browser will be opened, then a dialog box will be opened, when this happens, don't move your mouse nor use your keyboard, because they will be used to automate the file sending process.
Send document files
whatsapp.send_doc('123456789', 'path/to/your/doc.pdf')
As always, you can schedule it
whatsapp.send_doc('123456789', 'path/to/your/doc.pdf', instantly=False, hour='14', min='15')
Just like with files, you can choose a upload waiting time
whatsapp.send_doc('123456789', 'path/to/your/doc.pdf', '5', False, '14', '15')
Requirements
- Google Chrome version 115
- On linux, use xorg display server
- before running the script, download the following pyautogui dependencies:
sudo apt install scrot
sudo apt install python3-tk
sudo apt install python3-dev
Recommendations
- When using send_file or send_doc methods, make sure that your directories or files do not have any accent, like ã, ê, ñ etc.
- Before using this script, open your browser with your whatsapp web account logged in and let it load your messages. Whatsapp web almost always backup your messages and this time loading the messages can break the script.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.