-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbot.py
More file actions
106 lines (79 loc) · 2.82 KB
/
bot.py
File metadata and controls
106 lines (79 loc) · 2.82 KB
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
import os
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
PROMISED_DOWN = 150
PROMISED_UP = 10
TWITTER_EMAIL = "arpitsengar99@gmail.com"
TWITTER_PASSWORD = os.getenv("PASSWORD")
class InternetSpeedTwitterBot:
def __init__(self, driver_path):
self.driver = webdriver.Chrome(executable_path=driver_path)
self.down = 0
self.up = 0
def get_internet_speed(self):
self.driver.maximize_window()
self.driver.get(url="https://www.speedtest.net/")
time.sleep(2)
self.driver.find_element(By.ID, 'onetrust-accept-btn-handler').click()
self.driver.find_element(By.CLASS_NAME, 'start-text').click()
time.sleep(60)
self.down = self.driver.find_element(By.CLASS_NAME, 'download-speed').text
self.up = self.driver.find_element(By.CLASS_NAME, 'upload-speed').text
print(f"Download speed : {self.down}")
print(f"Upload speed : {self.up}")
def tweet_at_provider(self):
driver = self.driver
driver.get(url="https://twitter.com/login")
time.sleep(2)
url_link = 'https://twitter.com/login'
self.driver.get(url_link)
time.sleep(6)
login_btn = self.driver.find_element(By.CLASS_NAME, 'r-30o5oe')
login_btn.send_keys(TWITTER_EMAIL)
print(login_btn)
time.sleep(6)
next_btn = self.driver.find_elements(By.CLASS_NAME, 'css-901oao')
for item in next_btn:
try:
if item.text == 'Next':
try:
item.click()
except:
pass
except:
pass
time.sleep(2)
password = self.driver.find_element(By.NAME, 'password')
time.sleep(1)
password.send_keys(TWITTER_PASSWORD)
time.sleep(1)
time.sleep(2)
next_btn = self.driver.find_elements(By.CLASS_NAME, 'css-901oao')
for item in next_btn:
try:
if item.text == 'Log in':
try:
item.click()
except:
pass
except:
pass
time.sleep(2)
text_tweet = f"My current speed is {self.up} and {self.down}"
new_tweet = self.driver.find_element(By.CLASS_NAME, 'public-DraftStyleDefault-block')
new_tweet.send_keys(text_tweet)
time.sleep(2)
tweet_btn = self.driver.find_elements(By.CLASS_NAME, 'css-901oao')
for item in tweet_btn:
try:
if item.text == 'Tweet':
try:
item.click()
except:
pass
except:
pass
time.sleep(15)
self.driver.close()
self.driver.quit()