-
Notifications
You must be signed in to change notification settings - Fork 1
/
check_internet_speed.py
62 lines (48 loc) · 2.1 KB
/
check_internet_speed.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
from selenium import webdriver
import time
class SpeedCheck:
def __init__(self):
self.driver = webdriver.Chrome(executable_path="_YOUR_DRIVER_PATH_")
self.webpage = "https://www.speedtest.net/"
def get_speed(self):
self.driver.get(self.webpage)
print(">>> webpage loaded")
time.sleep(2)
go_button = self.driver.find_element_by_class_name("start-text")
go_button.click()
print(">>> scan begun")
print("wait...")
time.sleep(60)
print(">>> scan complete")
time.sleep(2)
def download_speed(self):
print(">>> getting download")
download_check = self.driver.find_element_by_css_selector(
"#container > div > div.main-content > div > div > div > "
"div.pure-u-custom-speedtest > "
"div.speedtest-container.main-row > div.main-view > div > "
"div.result-area.result-area-test > div > div > "
"div.result-container-speed.result-container-speed-active "
"> div.result-container-data > "
"div.result-item-container.result-item-container-align"
"-center > div > div.result-data.u-align-left > span")
download_result = download_check.text
print(f'{download_result}Mbps')
return download_result
def upload_speed(self):
time.sleep(1)
print(">>> getting upload")
upload_check = self.driver.find_element_by_css_selector(
"#container > div > div.main-content > div > div > div > "
"div.pure-u-custom-speedtest > "
"div.speedtest-container.main-row > div.main-view > div > "
"div.result-area.result-area-test > div > div > "
"div.result-container-speed.result-container-speed-active > "
"div.result-container-data > "
"div.result-item-container.result-item-container-align-left "
"> div > div.result-data.u-align-left > span")
upload_result = upload_check.text
print(f'{upload_result}Mbps')
return upload_result
def quit(self):
self.driver.quit()