-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtyperacer_script.py
More file actions
40 lines (33 loc) · 951 Bytes
/
Copy pathtyperacer_script.py
File metadata and controls
40 lines (33 loc) · 951 Bytes
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
import time
import pyautogui
import keyboard
from selenium import webdriver
from bs4 import BeautifulSoup
from selenium.webdriver.chrome.options import Options
def get_text(driver):
time.sleep(1)
src = driver.page_source
soup = BeautifulSoup(src,"html.parser")
span = soup.findAll("span")
text = ""
for i in span:
if "incomplete current" or "incomplete" in str(i):
text += i.text
if not text:
print("no txt")
return None
else:
print("text to type: ", text)
return text
def type_text(text):
pyautogui.typewrite(text)
def main():
chrome_options = Options()
chrome_options.add_experimental_option("detach",True)
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://humanbenchmark.com/tests/typing")
keyboard.wait("CTRL + ALT + 1")
text_to_type = get_text(driver)
if text_to_type:
type_text(text_to_type)
main()