0

Is it possible to make a program in python in which the program will look for a message on WhatsApp sent by a particular person on a group(which I have pinned for convenience) at a particular time and then it will print the message sent by that person?

Well if you don't understand my question let me give you an example:

Suppose there is a group named ABCD which is pinned on WhatsApp web(which means it is at the top)

It consists of 4 people - A,B,C,D

I want the program to print the message sent by C at time 13:05 in that group

Is this thing possible on python? I can use any module like selenium or even pyautogui

1 Answer 1

1

Yes, it is possible through Selenium without using any kind of API.

First we will import required modules:

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
import time

Now we will launch Whatsapp Web:

driver = webdriver.Chrome()
driver.get("https://web.whatsapp.com")

You can use other browsers, for this example we will be using Chrome.

Now we will locate the Search or Start New Chat button using XPath and add a webdriver wait for it:

search_button = WebDriverWait(driver,50).until(lambda driver: driver.find_element_by_xpath("//input[@title='Search or start new chat']"))

Now we will click it and add a little sleep:

search_button.click()
time.sleep(2)

Now we will Send the name of the Person to contact into the text area:

search_button.send_keys("A")
time.sleep(2)

Now we will send a message

input_box = driver.find_element_by_xpath(r'//div[@class="_2S1VP copyable-text selectable-text"][@contenteditable="true"][@data-tab="1"]')
time.sleep(2)
input_box.send_keys("Hello" + Keys.ENTER)
time.sleep(2)

You can using Chrome inspect more and do more things.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.