-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhatsapp_script.py
More file actions
38 lines (26 loc) · 978 Bytes
/
whatsapp_script.py
File metadata and controls
38 lines (26 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import json
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
# Read the JSON file
with open('data.json', 'r') as json_file:
data = json.load(json_file)
# Access Only Phone Number from the JSON file
Pnum = data.get("name")
url="https://web.whatsapp.com/"
browser = webdriver.Firefox()
browser.get(url)
browser.implicitly_wait(10)
# Link to Phone Button
time.sleep(5)
# Linkpn = browser.find_element(By.XPATH,"/html/body/div[1]/div/div/div[2]/div[3]/div[1]/div/div/div[3]/div/span")
Linkpn = browser.find_element(By.CSS_SELECTOR,"span.x1n68mz9")
Linkpn.click()
time.sleep(3)
# Enter Phone number Input Box
Phone = browser.find_element(By.XPATH,"/html/body/div[1]/div/div/div[2]/div[3]/div[1]/div/div[3]/div[1]/div[2]/div/div/div/form/input")
Phone.send_keys(Pnum)
time.sleep(3)
# Next Button
nxt = browser.find_element(By.XPATH,"/html/body/div[1]/div/div/div[2]/div[3]/div[1]/div/div[3]/div[3]/button/div/div")
nxt.click()