-
Notifications
You must be signed in to change notification settings - Fork 1
/
whatsappbot.py
35 lines (28 loc) · 1005 Bytes
/
whatsappbot.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
from selenium import webdriver
class Bot:
def __init__(self, wurl = "https://web.whatsapp.com/"):
self.wurl = wurl
self.driver = webdriver.Firefox()
self.driver.get(wurl)
def start(self):
try:
self.qrcode = self.driver.find_element_by_class_name('qrcode')
return False
except:
return True
def getchat(self, chatid):
try:
self.chat = self.driver.find_element_by_xpath('//*[@title="' + chatid + '"]').find_element_by_xpath('../../../../../..')
self.chat.click()
return True
except:
return False
def sendmessage(self, message):
try:
self.input = self.driver.find_element_by_class_name('input')
self.input.send_keys(message)
self.sendbtn = self.driver.find_element_by_class_name('compose-btn-send')
self.sendbtn.click()
return True
except:
return False