WhatsApp message flooding with Python

23 Dec

This code can be used to send a set of images with caption repeatedly. You can change the number of executions and intervals.

from selenium import webdriver
#from import WebDriverWait
#from import Select
#from import By
#from selenium.webdriver.common.keys import Keys
from import Options
import time

contact = "Contact name" #specify the contact or group to whome you will send the msgs
#text = "Hey, this message was sent using python"
#filepath = 'D:/Userfiles/Desktop/Python Whatsapp/1.png'
driver = webdriver.Chrome() #we need to download chromedriver to the script directory for this to work.
driver.get("") #Open whatsapp web and scan qr code. then hit enter.
print("Scan QR Code, And then Enter")
print("Logged In")

#inp_xpath_search = "//input[@title='Search or start new chat']"
#input_box_search = WebDriverWait(driver,50).until(lambda driver: driver.find_element_by_xpath(inp_xpath_search))

#find your contact on the left pane and click on them to select.
selected_contact = driver.find_element_by_xpath("//span[@title='"+contact+"']")

#filepaths for your images.

#number of time the loop should run, each time sending one msg.
for m in range (0,10):
    #change the filepath each time.
    for key in filesforme:
            filepath_= (filesforme[key])

            #send an image then break out of loop. I think this loop is actually not needed.
            #i will work on it later
            for i in range(0,1):


                caption_button=driver.find_element_by_xpath('//div[@class="_1awRl copyable-text selectable-text"]')


#inp_xpath = ('//*[@id="main"]/footer/div[1]/div[2]/div/div[2]')
#input_box = driver.find_element_by_xpath(inp_xpath)
#for i in range(0,11):
#    input_box.send_keys(text + Keys.ENTER)
Leave a comment

Posted by on December 23, 2020 in Python


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: