1import pyperclip
2from selenium.webdriver.chrome.service import Service
3import undetected_chromedriver as webdriver
4from selenium.webdriver.common.by import By
5from selenium.webdriver.chrome.options import Options
6from selenium.webdriver.common.keys import Keys
7from selenium.webdriver.support.ui import WebDriverWait
8from selenium.webdriver.support import expected_conditions as EC
9from selenium.common.exceptions import NoSuchElementException, TimeoutException
10import re
11import time
12
13
14driver_path = "C://Program Files//Google//Chrome//Application//chrome.exe" # Update this path to match your driver location
15profile_path = "C://Users//perso//AppData//Local//Google//Chrome//User Data" # Update this path
16profile_name = "Profile 8"
17
18# Set Chrome options
19chrome_options = webdriver.ChromeOptions()
20chrome_options.arguments.append(f"--user-data-dir={profile_path}")
21chrome_options.arguments.append(f"--profile-directory={profile_name}")
22chrome_options.add_argument("--start-fullscreen")
23
24service = Service(driver_path)
25chrome_options.use_chromium = True
26driver = webdriver.Chrome(service=service, options=chrome_options)
27
28driver.get("https://web.whatsapp.com/")
29WebDriverWait(driver, 60).until(EC.presence_of_element_located((By.XPATH, "//span[@data-icon='new-chat-outline']")))
30numbers = [
31 {
32 "name": "Hello",
33 "number": "+625462482736"
34 }
35]
36for user in numbers:
37 try:
38 chat_button_icon = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//span[@data-icon='new-chat-outline']")))
39 chat_button_icon.click()
40 search_box = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@aria-label='Search name or number']")))
41 search_box.clear()
42 search_box.send_keys(user["number"])
43 time.sleep(30)
44 try:
45 invalid_warning = driver.find_element(By.XPATH, "//*[contains(text(), 'No results found for')]")
46 invalid = driver.find_element(By.XPATH, "//div[@aria-label='Back']//span[@aria-hidden='true']")
47 invalid.click()
48 continue
49 except NoSuchElementException:
50 pass
51 search_box.send_keys(Keys.ENTER)
52 message = f"""🚀 Your Friend or Relative ( Jennifer Wrieden ) Just Joined Lit Star! Don't Miss Out!
53
54Hey {user['name']},
55
56Your friend or Relative @magentatv202488 just joined Lit Star! 🎉 Stay connected, follow them, and see what they’re up to!
57
58🔥 Install now & join the fun!
59👉 https://play.google.com/store/apps/details?id=com.litstar
60
61After installing, tap below to view their profile:
62📸 https://www.litstar.iplust.in/app/user/462
63
64Engage, follow, and enjoy! 🚀✨
65
66Lit Star – Where Connections Shine! 🌟"""
67 pyperclip.copy(message)
68 time.sleep(1)
69 message_box = driver.switch_to.active_element
70 message_box.send_keys(Keys.CONTROL, 'v')
71 time.sleep(1)
72 message_box.send_keys(Keys.ENTER)
73 time.sleep(2)
74
75 except (NoSuchElementException, TimeoutException) as e:
76 print(f"Error sending message to {user['name']}: {e}")
77
78driver.quit()
Comments Of This Blog ...