-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitter_bot.py
71 lines (52 loc) · 1.73 KB
/
twitter_bot.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
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from tkinter import *
class twitter_bot:
def __init__(self,username,password):
self.username=username
self.password=password
self.bot=webdriver.Chrome()
def login(self):
bot=self.bot
bot.get('https://twitter.com/')
time.sleep(5)
email=bot.find_element_by_name('session[username_or_email]')
password=bot.find_element_by_name('session[password]')
email.clear()
password.clear()
email.send_keys(self.username)
password.send_keys(self.password)
password.send_keys(Keys.RETURN)
time.sleep(10)
def find_tweet(self,entry3):
bot=self.bot
bot.get('https://twitter.com/search?q='+str(entry3)+'&src=typed_query')
# while True:
# bot.execute_script('window.scrollTo(0,document.body.scrollHeight)')
# time.sleep(2)
# pyautogui.click(pyautogui.locateCenterOnScreen('1.png'),duration=2)
# time.sleep(3)
def execute():
log=twitter_bot(str(entry1.get()),str(entry2.get()))
log.login()
log.find_tweet(entry3.get())
window=Tk()
window.geometry("700x600")
emails=Label(window,text="enter your email here",font='times 24 bold')
emails.grid(row=0,column=0)
entry1=Entry(window)
entry1.grid(row=0,column=6)
password=Label(window,text="enter your password here",font='times 24 bold')
password.grid(row=2,column=0)
entry2=Entry(window)
entry2.grid(row=2,column=6)
hashtag=Label(window,text="enter your email here",font='times 24 bold')
hashtag.grid(row=3,column=0)
entry3=Entry(window)
entry3.grid(row=3,column=6)
b1=Button(window,text=" GO ",command=execute,width=12,bg='gray')
b1.grid(row=7,column=4)
window.mainloop()
# Manthan62882423
# Ami69092865