I want to code whatsapp phone number validator. The script will

Joined
Feb 20, 2023
Messages
1
Reaction score
0
I want to code python script. The script will take input phone numbers list from user and then it will check over whatsapp using selenium if its registered on whatsapp or not. The script will be able to check each and every number from the list if its registered it will display registered if its not it will display not registered .
Please check my code but its not working perfect:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

Initialize the webdriver for Firefox​

driver = webdriver.Firefox()

Open the WhatsApp Web interface​

driver.get(“https://web.whatsapp.com/”)

Wait for the user to scan the QR code and log in​

input(“Press Enter after scanning the QR code and logging in…”)

Open the file containing the phone numbers​

with open(“phone.txt”, “r”) as f:
for line in f:
# Strip any whitespace from the line
line = line.strip()
# Navigate to the WhatsApp Web search page
driver.get(f"WhatsApp Web“)
time.sleep(10) # wait for the page to load
# Check if the phone number is registered on WhatsApp
if driver.find_elements_by_xpath(”//button[contains(text(), ‘Send message’)]“):
print(f”{line} - Registered on WhatsApp")
else:
print(f"{line} - Not registered on WhatsApp")

Close the webdriver​

driver.quit()
 
Joined
Mar 5, 2023
Messages
36
Reaction score
12
something like this?

Python:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

# Initialize the webdriver for Firefox
driver = webdriver.Firefox()

# Open the WhatsApp Web interface
driver.get("https://web.whatsapp.com/")

# Wait for the user to scan the QR code and log in
input("Press Enter after scanning the QR code and logging in…")

# Open the file containing the phone numbers
with open("phone.txt", "r") as f:
    for line in f:
        # Strip any whitespace from the line
        line = line.strip()
        # Navigate to the WhatsApp Web search page
        driver.get(f"https://web.whatsapp.com/send?phone={line}")
        time.sleep(10) # wait for the page to load
        # Check if the phone number is registered on WhatsApp
        if driver.find_elements_by_xpath("//div[@class='_31gEB']"):
            print(f"{line} - Registered on WhatsApp")
        else:
            print(f"{line} - Not registered on WhatsApp")

# Close the webdriver
driver.quit()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top