Hackernoon logoHow to Build a 910-wpm Typing Bot with Just 12 Lines of Python by@Rishabh

How to Build a 910-wpm Typing Bot with Just 12 Lines of Python

Author profile picture


Hi, Go do something positive, like "following me". BYE!!!

pip install selenium
Code Snippet
# Importing required modules and initializing variables

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
import re
string = ''
# ______________________________________

# Opening thetypingcat.com on firefox

firefox = webdriver.Firefox()
# ______________________________________

# Using javascript to get the typing content from the website and storing value in "string" variable

for i in range(firefox.execute_script('return document.querySelectorAll(".line").length')):
	string += firefox.execute_script('return document.querySelectorAll(".line")['+str(i)+'].innerHTML')

string = re.sub(r'<[^>]*>','',string) #This line is just delete tags present inside string
# ______________________________________

# Selenium commands to type what is stored inside string variable on the focused screen

action = ActionChains(firefox)

# ______________________________________ END ______________________________________

That's All

Selenium is good but building a cool project from it is more than awesome. And now you know what kind of cool projects can be build through just a little bit of google search, viewing the DOM, and by understanding the technology.
Thanks for Reading till here  😏


The Noonification banner

Subscribe to get your daily round-up of top tech stories!