-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathwhatsapp.py
48 lines (36 loc) · 1.8 KB
/
whatsapp.py
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
37
38
39
40
41
42
43
44
45
46
47
48
#program by Akshayjyoti Bordoloi
#version 2.01
#testing date: September 7, 2021
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
import time
driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get('https://web.whatsapp.com/')
#Chrome opens
#Scan the QR code
print("\n\nPlease MAXIMIZE the WhatsApp window before proceeding...")
print("\n\nPlease ignore all warnings and enter name of user or group...\n\n")
name = input('Enter the name of user or group: ')
msg = input('Enter your message: ')
count = int(input('Enter the count: '))
gap = float(input('Interval (in seconds) between messages: '))
bot_prompt = input('Do you want to add bot prompt to your message? (Y/N) ').upper()
input('Enter anything after scanning QR code...')
user = driver.find_element_by_xpath('//span[@title = "{}"]'.format(name))
user.click()
#Entered the chat
msg_box = driver.find_element_by_xpath('//div[@data-tab = "9"]') #updated from last version: @data-tab = "1" #May require further updates based on Chrome version.
for i in range(count):
if bot_prompt == 'Y':
msg_final = '<Status: ' + str(i+1) + '/' + str(count) + '>' + msg
msg_box.send_keys(msg_final)
button = driver.find_element_by_class_name('_4sWnG') #updated from last version: _35EW6 #May require further updates based on Chrome version.
button.click()
if gap > 0:
time.sleep(gap)
msg_final = 'Hacking Complete!'
msg_box.send_keys(msg_final)
button = driver.find_element_by_class_name('_4sWnG') #updated from last version: _35EW6 #May require further updates based on Chrome version.
button.click()
time.sleep(30) #update: gives time for messages to be sent before closing the window
driver.close()