Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Python3 WhatsApp Spammer Code

Enter name etc after scanning the QR Code. The chat window of the person should exist in your chats list


Code
from selenium import webdriver

driver = webdriver.Firefox()
url = "https://web.whatsapp.com/"
driver.get(url)
name = input("Enter group or Person name :")
msg = input("Enter your message :")
count = int(input("Enter the number of times :"))

user = driver.find_element_by_xpath('//span[@title = "{}"]'.format(name))
user.click()

for i in range(count):
    driver.find_element_by_xpath('//*[@id="main"]/footer/div[1]/div[2]/div/div[2]').send_keys(msg)
    driver.find_element_by_xpath('//*[@id="main"]/footer/div[1]/div[3]/button').click()
Hello :)

it's a good start with selenium, congratulations!

Now u can start use suports of selenium like:
Code
from selenium.webdriver.support.ui import WebDriverWait
wait = WebDriverWait( browser, 5)

to wait for the page to load and avoid an error like this that happened to me when I ran your script:

Code
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //span[@title = "Só o que sobrou F.C."]

also u can search about 'phantomjs', stay the tip!!

EDITED: look for how to use cookies to automation tests, u can resolve the question of QRCode easily
(Dec 21, 2019 02:11 PM)duendeee Wrote:  Hello :)

it's a good start with selenium, congratulations!

Now u can start use suports of selenium like:
Code
from selenium.webdriver.support.ui import WebDriverWait
wait = WebDriverWait( browser, 5)

to wait for the page to load and avoid anerror like this that happened to me when I ran your script:

Code
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //span[@title = "Só o que sobrou F.C."]

also u can search about 'phantomjs', stay the tip!!

EDITED: look for how to use cookies to automation tests, u can resolve the question of QRCode easily

Hey! Thanks for the feedback. I didn't put the code for driver to wait because if you are using this code you have to manually enter the name to spam and the message AFTER scanning the QR.

Could you provide me a link to the page where this QR code is taken care of?


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by 0u1lawAug 28, 2020 01:22 PM 6 356 Aug 28, 2020 01:22 PM
Last Post: Pernat1y
[Python] by 4rmaged0nDec 22, 2019 04:44 AM 3 320 Dec 22, 2019 04:44 AM
Last Post: Emp3hack
[Python] by 4rmaged0nNov 26, 2019 07:42 AM 7 240 Nov 26, 2019 07:42 AM
Last Post: Kallu609