-
Notifications
You must be signed in to change notification settings - Fork 4
/
whatsapp-sender.py
46 lines (35 loc) · 1.25 KB
/
whatsapp-sender.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
from selenium import webdriver
import csv
import time
messagesss = input(str("What's the message = "))
filesss = input(str("File of contacts = "))
users = []
with open(r"{}".format(filesss), encoding='UTF-8') as f:
rows = csv.reader(f,delimiter=",",lineterminator="\n")
next(rows, None)
for row in rows:
user = row[0]
users.append(user)
class WhatsappBot:
def __init__(self):
self.mensagem = messagesss
self.contatos = users
options = webdriver.ChromeOptions()
options.add_argument('lang=pt-br')
self.driver = webdriver.Chrome(executable_path = './chromedriver')
def SendMessages(self):
linkWhatsAppCheck = 'https://web.whatsapp.com/'
self.driver.get(linkWhatsAppCheck)
time.sleep(10)
for contato in self.contatos:
try:
link = 'https://web.whatsapp.com/send?phone='+ contato + '&text=' + self.mensagem
self.driver.get(link)
time.sleep(5)
chat_box = self.driver.find_element_by_class_name('_1U1xa')
chat_box.click()
time.sleep(5)
except:
pass
bot = WhatsappBot()
bot.SendMessages()