-
Notifications
You must be signed in to change notification settings - Fork 18
/
DMer.py
93 lines (64 loc) · 2.27 KB
/
DMer.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
import time
import schedule
x = 0
def dmer():
global x
usrnames = ['instagram', 'twitter'] # username whom you will send the message
chrome_options = Options()
chrome_options.add_argument(
'--user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1')
browser = webdriver.Chrome("chromedriver.exe", options=chrome_options)
browser.get('https://www.instagram.com/accounts/login/')
time.sleep(2)
usrname_bar = browser.find_element_by_name('username')
passwrd_bar = browser.find_element_by_name('password')
username = 'USERNAME' # Enter your username here
password = 'PASSWORD' # Enter your password here
usrname_bar.send_keys(username)
passwrd_bar.send_keys(password + Keys.ENTER)
time.sleep(11)
def send_msg(usrnames):
browser.get('https://www.instagram.com/direct/new/')
time.sleep(5)
to_btn = browser.find_element_by_name('queryBox')
to_btn.send_keys(usrnames)
time.sleep(8)
chk_mrk = browser.find_element_by_class_name('dCJp8')
chk_mrk.click()
time.sleep(3)
nxt_btn = browser.find_element_by_xpath('//div[@class="mXkkY KDuQp"]')
nxt_btn.click()
time.sleep(6)
txt_box = browser.find_element_by_tag_name('textarea')
txt_box.send_keys(f"Hi @{usrnames} ! What's up ?") # Customize your message
time.sleep(2)
snd_btn = browser.find_elements_by_css_selector('.sqdOP.yWX7d.y3zKF')
snd_btnn = snd_btn[len(snd_btn)-1]
snd_btnn.click()
time.sleep(4)
count = 0
try:
for usrnamee in usrnames:
send_msg(usrnamee)
count += 1
except TypeError:
print('Failed!')
browser.quit()
print(f'''
Successfully Sent {count} Massages
''')
x += 1
timee = "08:51" # Specific Time When The message will be send
try:
schedule.every().day.at(timee).do(dmer)
except TypeError:
pass
try:
while True and x != 1:
schedule.run_pending()
time.sleep(1)
except UnboundLocalError:
pass