from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from urllib.parse import quote
import time
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)
time.sleep(40)
for num in number:
link2 = f'https://web.whatsapp.com/send/?phone=91{num}&text;={msg}'
driver.get(link2)
print("link"+link2)
time.sleep(15)
action = ActionChains(driver)
time.sleep(100)
attachment_btn = driver.find_element(By.XPATH,'//*[@id="main"]/footer/div[1]/div/span[2]/div/div[1]/div[2]/div/div')
attachment_btn.click()
time.sleep(20)
image_btn = driver.find_element(By.XPATH,'//*[@id="main"]/footer/div[1]/div/span[2]/div/div[1]/div[2]/div/span/div/ul/div/div[2]/li/div')
#image_btn = driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div[5]/div/footer/div[1]/div/span[2]/div/div[1]/div[2]/div/span/div/ul/div/div[2]/li/div/span")
time.sleep(20)
image_btn.send_keys('E:\FITECH\Contacts\Whatsapp send automation\spring-boot-microservices-online-training.jpeg') # Replace with your image file path
action.send_keys(Keys.ENTER)
action.perform()
time.sleep(10)
time.sleep(2000)
{"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"}