Wondering how to send WhatsApp messages using Python using only 3 lines of code? You have come to the right place!
You can do so by using a simple tool wappdriver
.
Look!
Installation?
Its hassle-free.
Just pip install wappdriver
Why wappdriver?
- fast and reliable
- WhatsApp's website structure may change, the selectors can be updated over the internet dynamically, without changing code.
- chrome Driver path setting is hassle-free
- actively maintained
- fast support, if you need help
- send messages with bold, italics, or strikethrough
- send emojis smiley
- send images, videos, and gifs
- send documents and files
- can set a custom timeout, so that runs properly on old computers or with a slow internet connection
- more features to be added
Requirements
Just Chrome Browser and Chrome Driver.
Documentation
Just go to https://aahnik.github.io/wappdriver. You will get all details.
Note
This code is in no way affiliated with, authorized, maintained, sponsored, or endorsed by WhatsApp or any of its affiliates or subsidiaries. This is an independent and unofficial software.
This project is distributed under the MIT License.
Questions or Suggestions?
If you have any questions, or if you want to discuss something with the community, please come to the wappdriver Discussion Forum.
Top comments (20)
I added the wrong path how and then keep getting the error of "Chromedriver not loaded"
How do I change the path so it can work again?
EDIT: I found the GitHub discussion of changing your set PATH but now I am getting an error about unicode truncation after I made it into a raw string I get a permisson error.
github.com/aahnik/wappdriver/discu...
I'm gettting the error: "ChromeDriver not loaded". Could you provide any help?
Please post the details in the discussion forum.
github.com/aahnik/wappdriver/discu...
Please provide additional details.
have you installed chrome driver ? the correct matching verison ?
have you entered the correct path when prompted ?
Hi José,
Set the ChromeDriver path when you call the webdriver.Chrome.
eg:
browser = webdriver.Chrome('/home/user/Python/ChromeDriver/chromedriver')
browser.get('twitter.com')
anyone have this error like me
Traceback (most recent call last):
File "test_whatsapp.py", line 1, in
from wappdriver import WhatsApp
File "/home/username/.local/lib/python3.8/site-packages/wappdriver/init.py", line 24, in
from .local import set_chrome_driver_path, update_selectors
File "/home/username/.local/lib/python3.8/site-packages/wappdriver/local.py", line 11, in
from verlat import latest
ImportError: cannot import name 'latest' from 'verlat' (/home/username/.local/lib/python3.8/site-packages/verlat/init.py)
Can we also send messages to groups or only to people?
you can send messages to groups also. just put the name of group, in the
to
parameterYou can send messages to Groups also. Just use the name of the group in the recipient's name.
Do we need to be logged in WhatsApp web for it to work? I didn't quite understand how it sends the message. Also, what about contacts saved as numbers only (no name but only phone number)?
Hi ! Thanks for asking. When you run the code shown, chrome will open whatsapp web. For the first time you need to scan QR code to login to whatsapp.
You can send only to saved contacts.
Otherwise whatsapp may block you for spamming.
For contacts saved only as phone number, it will work. Just put the phone number instead of name , in the
to
parameter of thesend
methodAmazing! Do we need to include the full number (with country code) like +1123456789 or only 123456789 will work?
exactly same as saved. Number must be saved
It doesn't support if the name contains space.
can you show a screen recording ? or terminal output ?
it is expected to work
hii aahnik
i check your github
s link (full documentation), but it links to same page, i
m looking for a way to send some pdf files to some different people.Hello I have this error
cannot import name 'WhatsApp' from partially initialized module 'wappdriver' (most likely due to a circular import)
did you name your file
wappdriver.py
? Dont do that. Learn more about imports.And by the way, wappdriver is not more maintained. See the github repo for notice.
Some comments may only be visible to logged-in visitors. Sign in to view all comments. Some comments have been hidden by the post's author - find out more