70
How to annoy your friends on WhatsApp?
There are various ways to annoy your friends but being a programmer(); I should do it with my weapon known as CODE. π¨βπ»
Let's dive into it. π
We will be using
python
as a programming language and selenium
to automate messaging. Use this link to download ChromeDriver and extract the zip file.
Note: Download according to the version of Chrome installed on your system.
Note: Download according to the version of Chrome installed on your system.
We need to install the selenium python package.
Open the terminal and run the command
Open the terminal and run the command
pip install selenium
.Learn more about Selenium here
Time to code (); π
filename.py
in any code editor. (I am using PyCharm)from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
# About Selenium - https://www.selenium.dev/
# Getting Chrome Driver
driver = webdriver.Chrome(r"D:\Softwares\chromedriver_win32\chromedriver.exe") #put path of chromedriver.exe
driver.get('https://web.whatsapp.com/')
# Number of messages you want to spam
MESSAGE_COUNT = 10
# Sends Message
def sendMessage(msg):
# Entering message in chat box
WebDriverWait(driver, 100).until(
EC.element_to_be_clickable((By.XPATH, '//*[@id="main"]/footer/div[1]/div[2]/div/div[2]'))).send_keys(msg)
# Clicking SEND button
WebDriverWait(driver, 100).until(
EC.element_to_be_clickable((By.XPATH, '//*[@id="main"]/footer/div[1]/div[2]/div/div[2]'))).send_keys(
Keys.RETURN)
flag = True
while flag:
name = input("Enter Contact Name (Type \'exit\' to end the program) :") #type exit to end program
if name == "exit":
flag = False
else:
# How to get XPath of HTML element? -
# Learn at https://ajaygalagali.hashnode.dev/how-to-get-xpath-of-html-element
# To know more about XPATH visit - https://developer.mozilla.org/en-US/docs/Web/XPath
# Clicking on Search
WebDriverWait(driver, 100).until(
EC.element_to_be_clickable((By.XPATH, '//*[@id="side"]/div[1]/div/label/div/div[2]'))).click()
# Entering contact name
WebDriverWait(driver, 100).until(
EC.element_to_be_clickable((By.XPATH, '//*[@id="side"]/div[1]/div/label/div/div[2]'))).send_keys(name)
# Opening chat of contact
WebDriverWait(driver, 100).until(
EC.element_to_be_clickable((By.XPATH, '//*[@id="side"]/div[1]/div/label/div/div[2]'))).send_keys(
Keys.RETURN)
# Spamming messages
for i in range(MESSAGE_COUNT):
sendMessage(i)
sendMessage("These messages are sent by Python Program!")
sendMessage("Learn here: https://ajaygalagali.hashnode.dev/")
See to it that package is imported successfully.



Here, I sent 11 messages for demo purposes. You can send 1000s of messages too.
You can change the variable MESSAGE_COUNT
in the program to any number, that number of messages will be spammed to your friend.
Are they gonna get annoyed by just 11 messages? No way!
Listen to my story! I programmed to send 10k messages to my close friend's group. Around 50 messages were sent into the group and admin kicked me out of the group π. Admin with a brain! π.
Well, title should be How to get kicked out of WhatsApp group without being mean? π
Listen to my story! I programmed to send 10k messages to my close friend's group. Around 50 messages were sent into the group and admin kicked me out of the group π. Admin with a brain! π.
Well, title should be How to get kicked out of WhatsApp group without being mean? π

lol xD
Keep annoying friends π
β Check out original blog here
70