1
+ from selenium import webdriver
2
+ from selenium .webdriver .common .keys import Keys
3
+ from selenium .common .exceptions import NoSuchElementException
4
+ import mycontacts
5
+ import tkinter as tk
6
+ from tkinter import *
7
+ import xpath
8
+ import time
9
+
10
+ #Function checking whether the given user exists in the user's whatsapp contact list
11
+ def checkuser (str ):
12
+ try :
13
+ driver .find_element_by_xpath (str )
14
+ except NoSuchElementException :
15
+ return False
16
+ return True
17
+ # Taking all the Credentials from the user
18
+ contact_name = []
19
+ print ("\n \n Enter the name of the contact you want to send message to (Type 'ALL' if you want to send message to all your contacts: )" )
20
+ print (R"For multiple contacts use newline and type 'stop' at the end to stop adding contacts: " )
21
+ while (1 ):
22
+ a = input ()
23
+ if (a == "stop" ):
24
+ break
25
+ contact_name .append (a )
26
+
27
+ print ("Enter the message you want to send:- " , end = " " )
28
+ message = input ()
29
+
30
+ print ("Enter the number of times you want to bomb the message to your contact: " , end = " " )
31
+ count_message = int (input ())
32
+
33
+
34
+ #defining the driver for the chrome
35
+ driver = webdriver .Chrome ()
36
+ d1 = driver .get ("https://web.whatsapp.com/" )
37
+ driver .maximize_window ()
38
+ time .sleep (10 )
39
+
40
+ #If the user chooses ALL then the message will be sent to all the contacts added in mycontacts.py
41
+ if ("ALL" in contact_name ):
42
+ for contact in mycontacts .my_contacts :
43
+
44
+ #locating the chat icon using xpath
45
+ chat = driver .find_element_by_xpath (xpath .newchat_xpath )
46
+ chat .click ()
47
+
48
+ #locating the search box using xpath and adding the contact to search
49
+ search = driver .find_element_by_xpath (xpath .search_xpath )
50
+ search .send_keys (contact )
51
+ time .sleep (1 )
52
+
53
+ #Checking whether the contact exist or not
54
+ if (checkuser ("//span[@title='{}']" .format (contact )) == False ):
55
+ continue
56
+
57
+ #Searching the contact and clicking on it
58
+ find_user = driver .find_element_by_xpath ("//span[@title='{}']" .format (contact ))
59
+ find_user .click ()
60
+ time .sleep (1 )
61
+
62
+ #Finding the box to type the message and clicking on it
63
+ find_message = driver .find_element_by_xpath (xpath .message_xpath )
64
+ find_message .click ()
65
+ time .sleep (1 )
66
+
67
+ #Sending the messages on the basis of count given by the user
68
+ for i in range (count_message ):
69
+ find_message .send_keys (message )
70
+ driver .find_element_by_xpath (xpath .sendbutton_xpath ).click ()
71
+ time .sleep (0.5 )
72
+ time .sleep (1 )
73
+ #Else the messages will be sent to the users mentioned in the input
74
+ else :
75
+ for contact in contact_name :
76
+ chat = driver .find_element_by_xpath (xpath .newchat_xpath )
77
+ chat .click ()
78
+
79
+ search = driver .find_element_by_xpath (xpath .search_xpath )
80
+ search .send_keys (contact )
81
+ time .sleep (1 )
82
+
83
+ if (checkuser ("//span[@title='{}']" .format (contact )) == False ):
84
+ continue
85
+
86
+ find_user = driver .find_element_by_xpath ("//span[@title='{}']" .format (contact ))
87
+ find_user .click ()
88
+ time .sleep (1 )
89
+
90
+ find_message = driver .find_element_by_xpath (xpath .message_xpath )
91
+ find_message .click ()
92
+ time .sleep (1 )
93
+
94
+ for i in range (count_message ):
95
+ find_message .send_keys (message )
96
+ driver .find_element_by_xpath (xpath .sendbutton_xpath ).click ()
97
+ time .sleep (0.5 )
98
+ time .sleep (1 )
99
+
100
+ print ("Sms Bombing Completed...!!!!" )
0 commit comments