WhatsApp using Python
2.Installation of Selenium WebDriver
pip install selenium
For Python 3 you can install given as below.
pip3 install selenium
from selenium import webdriver
driver = webdriver.Chrome(‘/home/saket/Downloads/chromedriver’)
target = ‘”Friend’s Name”‘
string = “Message sent using Python!!!”
x_arg = ‘//span[contains(@title,’ + target + ‘)]’
group_title = wait.until(EC.presence_of_element_located((By.XPATH, x_arg)))group_title.click()
inp_xpath = ‘//div[@class=”input”][@dir=”auto”][@data-tab=”1″]’
input_box = wait.until(EC.presence_of_element_located((By.XPATH, inp_xpath)))
for i in range(100):
input_box.send_keys(string + Keys.ENTER)
Keep your mobile with you. Choose the WhatsApp web from the highest bar in WhatsApp(3 dots).
Connect your mobile with web.whatsapp.com by scanning QR code which scans in your mobile.
Then run the script ( confirm that you simply have added absolutely the path for chrome driver and have replaced target variable together with your friend’s name ). Scan the QR code that appears on the screen and luxuriate in the facility of python!
Please use this script only for educational purposes, i am not responsible if your friends ( or even Whatsapp ) block you.
For Practise purpose you can watch the following video which helps you a lot.