-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspeed-test.py
More file actions
40 lines (29 loc) · 1.06 KB
/
speed-test.py
File metadata and controls
40 lines (29 loc) · 1.06 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
## Speed Test Usage
# Create and activate a virtual environment:
# python3 -m venv venv
# source venv/bin/activate (Mac/Linux)
# venv\Scripts\activate (Windows)
# Install required dependencies:
# pip3 install selenium webdriver-manager
# Run the script:
# python3 speed-test.py
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
import time
# Setup Chrome with options
chrome_options = Options()
chrome_options.add_argument("--headless") # Optional: Runs in background
# Start the browser
browser = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
# Open Fast.com
browser.get("https://fast.com")
# Wait for speed test to complete
time.sleep(15) # Adjust if needed
# Get the speed result
speed = browser.find_element(By.CLASS_NAME, "speed-results-container").text
print(f"Download Speed: {speed} Mbps")
# Close the browser
browser.quit()