from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from urllib.parse import quote
from time import sleep
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
with open('msg2.txt', 'r') as file:
msg = file.read()
msg = quote(msg)
number = []
with open('numbers.txt', 'r') as file:
for num in file.readlines():
number.append(num.rstrip())
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
link = 'https://web.whatsapp.com/'
driver.get(link)
sleep(2)
WebDriverWait(driver, 40).until(EC.presence_of_element_located((By.XPATH, '//*[@id="app"]/div/div[2]/div[3]/header')))
for num in number:
link2 = f'https://web.whatsapp.com/send/?phone=91{num}&text;={msg}'
driver.get(link2)
Pathurl = '//*[@id="app"]/div/span[2]/div/span/div/div/div/div/div/div[1]'
if Pathurl=='//*[@id="app"]/div/span[2]/div/span/div/div/div/div/div/div[1]':
driver.find_element(By.XPATH,'//*[@id="app"]/div/span[2]/div/span/div/div/div/div/div/div[2]/div/button/div/div').click()
continue
#Message #/html/body/div[1]/div/span[2]/div/span/div/div/div/div/div/div[1]
#Ok #/html/body/div[1]/div/span[2]/div/span/div/div/div/div/div/div[2]/div/button/div/div
# driver.find_element(By.XPATH,'//*[@id="app"]/div/span[2]/div/span/div/div/div/div/div/div[2]/div/button/div/div').click()
#//*[@id="app"]/div/span[2]/div/span/div/div/div/div/div/div[1]
#//*[@id="app"]/div/span[2]/div/span/div/div/div/div/div/div[2]/div/button/div/div
WebDriverWait(driver, 150).until(EC.presence_of_element_located((By.XPATH, '//div[@title="Attach"]')))
sleep(2)
driver.find_element(By.XPATH,'//div[@title="Attach"]').click()
WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, '//span[contains(text(),"Photos & Videos")]/../input')))
image_btn = driver.find_element(By.XPATH,'//span[contains(text(),"Photos & Videos")]/../input')
image_btn.send_keys('E:FITECHContactsWhatsapp send automationJava banner.png')
WebDriverWait(driver, 2).until(EC.presence_of_element_located((By.XPATH, '//span[@data-icon="send"]')))
sleep(2)
driver.find_element(By.XPATH,'//span[@data-icon="send"]/..').click()
sleep(5)
print("Done")
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}