-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathinstabot.py
143 lines (115 loc) · 4.39 KB
/
instabot.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# importing module
from selenium import webdriver
import os
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.common.keys import Keys
from webdriver_manager.chrome import ChromeDriverManager
import tkinter as tk
from tkinter import messagebox
import pyttsx3
driver = webdriver.Chrome(ChromeDriverManager().install())
def login():
try:
if ent2.get() != str(ent2.get()):
pass
except:
tk.messagebox.showerror(
title="FAILED",
message="\t\t Oops! \n You have entered wrong value. Numbers can't be text values!!! \n BYE"
)
driver.close
tk.messagebox.showinfo(
title="SUCCESS",
message=f"\t\tCongratulations!\n\n You are sending {str(ent1.get('1.0', tk.END))} text to {str(ent2.get())}"
)
print('5')
driver.get('https://www.instagram.com/')
username = str(ent3.get())
password = str(ent4.get())
message = str(ent1.get('1.0', tk.END))
user = str(ent2.get()).split()
enter_username = WebDriverWait(driver, 20).until(
expected_conditions.presence_of_element_located((By.NAME, 'username')))
enter_username.send_keys(username)
enter_password = WebDriverWait(driver, 20).until(
expected_conditions.presence_of_element_located((By.NAME, 'password')))
enter_password.send_keys(password)
enter_password.send_keys(Keys.RETURN)
time.sleep(5)
# first pop-up
driver.find_element_by_xpath(
'//*[@id="react-root"]/section/main/div/div/div/div/button').click()
time.sleep(2)
# 2nd pop-up
driver.find_element_by_xpath(
'/html/body/div[4]/div/div/div/div[3]/button[2]').click()
time.sleep(2)
# direct button
driver.find_element_by_xpath(
'//*[@id="react-root"]/section/nav/div[2]/div/div/div[3]/div/div[2]/a').click()
time.sleep(3)
# clicks on pencil icon
driver.find_element_by_xpath(
'//*[@id="react-root"]/section/div/div[2]/div/div/div[1]/div[1]/div/div[3]/button').click()
time.sleep(2)
for i in user:
# enter the username
driver.find_element_by_xpath(
'/html/body/div[5]/div/div/div[2]/div[1]/div/div[2]/input').send_keys(i)
time.sleep(2)
# click on the username
driver.find_element_by_xpath(
'/html/body/div[5]/div/div/div[2]/div[2]/div[1]/div/div[3]/button').click()
time.sleep(2)
# next button
driver.find_element_by_xpath(
'/html/body/div[5]/div/div/div[1]/div/div[2]/div/button').click()
time.sleep(3)
# click on message area
send = driver.find_element_by_xpath(
'//*[@id="react-root"]/section/div/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/div[2]/textarea')
# types message
send.send_keys(message)
time.sleep(1)
# send message
send.send_keys(Keys.RETURN)
time.sleep(2)
# clicks on direct option or pencl icon
driver.find_element_by_xpath(
'//*[@id="react-root"]/section/div/div[2]/div/div/div[1]/div[1]/div/div[3]/button').click()
time.sleep(2)
engine = pyttsx3.init()
engine.say("Welcome to Ali's Instagram Bot")
engine.runAndWait()
window = tk.Tk()
window.title("Instagram Bot by Ali")
window.geometry("800x400")
window.configure(bg="#494949")
tk.Label(window, text="Welcome", font=(
"Gill Sans", 36), bg="#F0FF00").pack(pady=10)
tk.Label(window, text="Type the text :- ",
font=("Gill Sans", 20), bg="#00FAFA").pack(pady=10)
ent1 = tk.Text(window)
ent1.place(x=10, y=120, height=100, width=750)
tk.Label(window, text="Enter usernames:- ",
font=("Gill Sans", 20), bg="#00FAFA").place(x=20, y=240)
ent2 = tk.Entry(window)
ent2.place(x=350, y=240, width=300)
tk.Label(window, text="Your username:-",
font=("Gill Sans", 20), bg="#00FAFA").place(x=20, y=280)
ent3 = tk.Entry(window)
ent3.place(x=20, y=320)
tk.Label(window, text="Your password:-",
font=("Gill Sans", 20), bg="#00FAFA").place(x=350, y=280)
ent4 = tk.Entry(window, show="*")
ent4.place(x=350, y=320)
button1 = tk.Button(window, text="SUBMIT",
font=("Gill Sans", 20), bg="#18D848",
command=login)
button1.place(x=350, y=360) # pack issue
window.mainloop()
# when our program ends it will show "done".
input("DONE")