Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e1530fc

Browse files
Merge pull request avinashkranjan#203 from vaishnavirshah/whatsapp-automation
Added the folder whatsapp-automation containing all the files
2 parents f2b961c + 318fb6c commit e1530fc

File tree

6 files changed

+50
-0
lines changed

6 files changed

+50
-0
lines changed
31.2 KB
Loading[フレーム]
67.7 KB
Loading[フレーム]

‎Whatsapp_Automation/README.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## How to run this Python Script?
2+
3+
1. Install [chromedriver](https://chromedriver.storage.googleapis.com/index.html?path=2.25/) ( choose your specific version )
4+
2. `pip install selenium`
5+
3. Make sure you have added the **correct path** to your chrome driver
6+
4. Enter the name of the person you want to send the message to **exactly the way it is saved.**
7+
5. Type in the message you want to send.
8+
6. You will have **15s** to scan for whatsapp web.
9+
7. Message has been sent.
10+
23.9 KB
Loading[フレーム]
134 KB
Loading[フレーム]
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Selenium is required for automation
2+
# sleep is required to have some time for scanning
3+
from selenium import webdriver
4+
from selenium.common.exceptions import NoSuchElementException
5+
from selenium.webdriver.support.ui import WebDriverWait
6+
from selenium.webdriver.support import expected_conditions as EC
7+
from selenium.webdriver.common.keys import Keys
8+
from selenium.webdriver.common.by import By
9+
from time import sleep
10+
11+
12+
def whatsapp(to, message):
13+
person = [to]
14+
string = message
15+
chrome_driver_binary = "C:\\Program Files\\Google\\Chrome\\Application\\chromedriver.exe"
16+
# Selenium chromedriver path
17+
driver = webdriver.Chrome(chrome_driver_binary)
18+
driver.get("https://web.whatsapp.com/")
19+
sleep(15)
20+
# This will find the person we want to send the message to in the list
21+
for name in person:
22+
user = driver.find_element_by_xpath("//span[@title='{}']".format(name))
23+
user.click()
24+
text_box = driver.find_element_by_xpath(
25+
'//*[@id="main"]/footer/div[1]/div[2]/div/div[2]')
26+
try:
27+
text_box.send_keys(string)
28+
sendbutton = driver.find_elements_by_xpath(
29+
'//*[@id="main"]/footer/div[1]/div[3]/button')[0]
30+
sendbutton.click()
31+
sleep(10)
32+
print('Message Sent!!')
33+
except:
34+
print('Error occured....')
35+
36+
37+
if __name__ == "__main__":
38+
to = input('Who do you want to send a message to? Enter the name: ')
39+
content = input("What message to you want to send? Enter the message: ")
40+
whatsapp(to, content)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /