admin管理员组文章数量:1025465
I was looking to have some fun and was annoying my friend by spam tagging him in a group chat . Then it hit me , why could i not write a for loop to spam his name as many times as i want .
I went to google and ChatGPT and it spat me out this
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdrivermon.by import By
from selenium.webdrivermon.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdrivermon.action_chains import ActionChains
import time
# Path to Brave Browser executable
brave_path = "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
# Path to ChromeDriver (if moved to /usr/local/bin, no need for full path)
chromedriver_path = "/usr/local/bin/chromedriver"
# Configure Selenium to use Brave
options = webdriver.ChromeOptions()
options.binary_location = brave_path
# Start WebDriver with Brave
driver = webdriver.Chrome(service=Service(chromedriver_path), options=options)
# Open WhatsApp Web
driver.get(";)
# Wait for login
input("Log in to WhatsApp Web and press Enter...")
# Example: Print the page title
print("Page title is:", driver.title)
# Wait for the search box to be available
wait = WebDriverWait(driver, 30) # Wait for up to 30 seconds
search_box = wait.until(EC.presence_of_element_located((By.XPATH, '//div[@contenteditable="true"][@data-tab="3"]')))
# Click on the search box and type the chat name
search_box.click()
search_box.send_keys("Group Name") # Replace with your group's name
search_box.send_keys(Keys.ENTER)
# Wait for the message box to be both present and visible
message_box = wait.until(EC.visibility_of_element_located((By.XPATH, '//div[@contenteditable="true"][@data-tab="1"]')))
time.sleep(2) # Optional: Add delay to ensure the message box is ready
# Initialize ActionChains
actions = ActionChains(driver)
# Send "@John" 100 times in the message box
for _ in range(100):
actions.move_to_element(message_box).click().send_keys("@John").perform()
actions.send_keys(Keys.SHIFT + Keys.ENTER).perform() # To create a new line without sending
# Finally, send the message
actions.send_keys(Keys.ENTER).perform()
# Close browser
driver.quit()
i have literally 0 clue about selenium and i do know a little about python. Just for the kicks can anyone help me . also i have setup chromium and everything on my machine and was able to login and navigate to the group chat properly just the script wasnt writing his name 100 times and sending it to him
also itll be a great help if the script would tag him a 100 times if possible . also we were gonna play CS-Go
Just for fun if anyone lurks around here, do share a help. Thanks .
I was looking to have some fun and was annoying my friend by spam tagging him in a group chat . Then it hit me , why could i not write a for loop to spam his name as many times as i want .
I went to google and ChatGPT and it spat me out this
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdrivermon.by import By
from selenium.webdrivermon.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdrivermon.action_chains import ActionChains
import time
# Path to Brave Browser executable
brave_path = "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
# Path to ChromeDriver (if moved to /usr/local/bin, no need for full path)
chromedriver_path = "/usr/local/bin/chromedriver"
# Configure Selenium to use Brave
options = webdriver.ChromeOptions()
options.binary_location = brave_path
# Start WebDriver with Brave
driver = webdriver.Chrome(service=Service(chromedriver_path), options=options)
# Open WhatsApp Web
driver.get("https://web.whatsapp")
# Wait for login
input("Log in to WhatsApp Web and press Enter...")
# Example: Print the page title
print("Page title is:", driver.title)
# Wait for the search box to be available
wait = WebDriverWait(driver, 30) # Wait for up to 30 seconds
search_box = wait.until(EC.presence_of_element_located((By.XPATH, '//div[@contenteditable="true"][@data-tab="3"]')))
# Click on the search box and type the chat name
search_box.click()
search_box.send_keys("Group Name") # Replace with your group's name
search_box.send_keys(Keys.ENTER)
# Wait for the message box to be both present and visible
message_box = wait.until(EC.visibility_of_element_located((By.XPATH, '//div[@contenteditable="true"][@data-tab="1"]')))
time.sleep(2) # Optional: Add delay to ensure the message box is ready
# Initialize ActionChains
actions = ActionChains(driver)
# Send "@John" 100 times in the message box
for _ in range(100):
actions.move_to_element(message_box).click().send_keys("@John").perform()
actions.send_keys(Keys.SHIFT + Keys.ENTER).perform() # To create a new line without sending
# Finally, send the message
actions.send_keys(Keys.ENTER).perform()
# Close browser
driver.quit()
i have literally 0 clue about selenium and i do know a little about python. Just for the kicks can anyone help me . also i have setup chromium and everything on my machine and was able to login and navigate to the group chat properly just the script wasnt writing his name 100 times and sending it to him
also itll be a great help if the script would tag him a 100 times if possible . also we were gonna play CS-Go
Just for fun if anyone lurks around here, do share a help. Thanks .
Share Improve this question asked Nov 17, 2024 at 12:52 RoooooKieRoooooKie 154 bronze badges1 Answer
Reset to default 1If using selenium library is not you priority, you can use a pyautogui
library to do that. To install it, just type in the terminal
pip install pyautogui
Here is an example application. If you are going to open your whatsapp group and select a box where you send messages in 10 seconds, an application is going to send 100 messages. Put as a message variable whatever you want to spam your friends with, and here you go!
import pyautogui, time
time.sleep(10) # 10 seconds delay so you can open whatsapp and your chat, and select a message box.
message = "Here you put any string you want to spam you friend with"
for i in range(100): # Do this 100 times
pyautogui.typewrite(message) # Writes a message into the whatsapp box
pyautogui.typewrite(["enter"]) # Sends the message
If you want to customize your code, here is the documentation of this library.
I was looking to have some fun and was annoying my friend by spam tagging him in a group chat . Then it hit me , why could i not write a for loop to spam his name as many times as i want .
I went to google and ChatGPT and it spat me out this
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdrivermon.by import By
from selenium.webdrivermon.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdrivermon.action_chains import ActionChains
import time
# Path to Brave Browser executable
brave_path = "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
# Path to ChromeDriver (if moved to /usr/local/bin, no need for full path)
chromedriver_path = "/usr/local/bin/chromedriver"
# Configure Selenium to use Brave
options = webdriver.ChromeOptions()
options.binary_location = brave_path
# Start WebDriver with Brave
driver = webdriver.Chrome(service=Service(chromedriver_path), options=options)
# Open WhatsApp Web
driver.get(";)
# Wait for login
input("Log in to WhatsApp Web and press Enter...")
# Example: Print the page title
print("Page title is:", driver.title)
# Wait for the search box to be available
wait = WebDriverWait(driver, 30) # Wait for up to 30 seconds
search_box = wait.until(EC.presence_of_element_located((By.XPATH, '//div[@contenteditable="true"][@data-tab="3"]')))
# Click on the search box and type the chat name
search_box.click()
search_box.send_keys("Group Name") # Replace with your group's name
search_box.send_keys(Keys.ENTER)
# Wait for the message box to be both present and visible
message_box = wait.until(EC.visibility_of_element_located((By.XPATH, '//div[@contenteditable="true"][@data-tab="1"]')))
time.sleep(2) # Optional: Add delay to ensure the message box is ready
# Initialize ActionChains
actions = ActionChains(driver)
# Send "@John" 100 times in the message box
for _ in range(100):
actions.move_to_element(message_box).click().send_keys("@John").perform()
actions.send_keys(Keys.SHIFT + Keys.ENTER).perform() # To create a new line without sending
# Finally, send the message
actions.send_keys(Keys.ENTER).perform()
# Close browser
driver.quit()
i have literally 0 clue about selenium and i do know a little about python. Just for the kicks can anyone help me . also i have setup chromium and everything on my machine and was able to login and navigate to the group chat properly just the script wasnt writing his name 100 times and sending it to him
also itll be a great help if the script would tag him a 100 times if possible . also we were gonna play CS-Go
Just for fun if anyone lurks around here, do share a help. Thanks .
I was looking to have some fun and was annoying my friend by spam tagging him in a group chat . Then it hit me , why could i not write a for loop to spam his name as many times as i want .
I went to google and ChatGPT and it spat me out this
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdrivermon.by import By
from selenium.webdrivermon.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdrivermon.action_chains import ActionChains
import time
# Path to Brave Browser executable
brave_path = "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
# Path to ChromeDriver (if moved to /usr/local/bin, no need for full path)
chromedriver_path = "/usr/local/bin/chromedriver"
# Configure Selenium to use Brave
options = webdriver.ChromeOptions()
options.binary_location = brave_path
# Start WebDriver with Brave
driver = webdriver.Chrome(service=Service(chromedriver_path), options=options)
# Open WhatsApp Web
driver.get("https://web.whatsapp")
# Wait for login
input("Log in to WhatsApp Web and press Enter...")
# Example: Print the page title
print("Page title is:", driver.title)
# Wait for the search box to be available
wait = WebDriverWait(driver, 30) # Wait for up to 30 seconds
search_box = wait.until(EC.presence_of_element_located((By.XPATH, '//div[@contenteditable="true"][@data-tab="3"]')))
# Click on the search box and type the chat name
search_box.click()
search_box.send_keys("Group Name") # Replace with your group's name
search_box.send_keys(Keys.ENTER)
# Wait for the message box to be both present and visible
message_box = wait.until(EC.visibility_of_element_located((By.XPATH, '//div[@contenteditable="true"][@data-tab="1"]')))
time.sleep(2) # Optional: Add delay to ensure the message box is ready
# Initialize ActionChains
actions = ActionChains(driver)
# Send "@John" 100 times in the message box
for _ in range(100):
actions.move_to_element(message_box).click().send_keys("@John").perform()
actions.send_keys(Keys.SHIFT + Keys.ENTER).perform() # To create a new line without sending
# Finally, send the message
actions.send_keys(Keys.ENTER).perform()
# Close browser
driver.quit()
i have literally 0 clue about selenium and i do know a little about python. Just for the kicks can anyone help me . also i have setup chromium and everything on my machine and was able to login and navigate to the group chat properly just the script wasnt writing his name 100 times and sending it to him
also itll be a great help if the script would tag him a 100 times if possible . also we were gonna play CS-Go
Just for fun if anyone lurks around here, do share a help. Thanks .
Share Improve this question asked Nov 17, 2024 at 12:52 RoooooKieRoooooKie 154 bronze badges1 Answer
Reset to default 1If using selenium library is not you priority, you can use a pyautogui
library to do that. To install it, just type in the terminal
pip install pyautogui
Here is an example application. If you are going to open your whatsapp group and select a box where you send messages in 10 seconds, an application is going to send 100 messages. Put as a message variable whatever you want to spam your friends with, and here you go!
import pyautogui, time
time.sleep(10) # 10 seconds delay so you can open whatsapp and your chat, and select a message box.
message = "Here you put any string you want to spam you friend with"
for i in range(100): # Do this 100 times
pyautogui.typewrite(message) # Writes a message into the whatsapp box
pyautogui.typewrite(["enter"]) # Sends the message
If you want to customize your code, here is the documentation of this library.
本文标签: pythonHow to send automated message in whatsapp desktopStack Overflow
版权声明:本文标题:python - How to send automated message in whatsapp desktop - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745634539a2160365.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论