Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from selenium import webdriver
- from selenium.webdriver.common.keys import Keys
- import time
- # Initialize WebDriver (Make sure the ChromeDriver path is correct)
- driver = webdriver.Chrome(executable_path='path/to/chromedriver')
- # Open WhatsApp Web
- driver.get("https://web.whatsapp.com")
- # Wait for the user to scan the QR code
- time.sleep(15) # Adjust the sleep time based on your needs
- # Function to send a message to a number
- def send_message(phone_number, message):
- url = f"https://wa.me/{phone_number}?text={message}"
- driver.get(url)
- # Wait for the page to load
- time.sleep(5)
- # Locate the "Send" button and click it
- send_button = driver.find_element_by_xpath("//button[@data-testid='compose-btn-send']")
- send_button.click()
- # List of phone numbers
- phone_numbers = ["1234567890", "0987654321"] # Add numbers in international format
- # Message to send
- message = "Hello, this is an automated message."
- # Loop through the numbers and send the message
- for number in phone_numbers:
- send_message(number, message)
- time.sleep(5) # Adjust the sleep time to allow for message sending
- # Close the browser after sending messages
- driver.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement