-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·48 lines (33 loc) · 1.38 KB
/
main.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
#! /usr/bin/env python3
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
import os
import time
url = "http://klavogonki.ru/g/?gmid=*******"
options = webdriver.FirefoxOptions()
options.set_preference('dom.webdriver.enabled', False)
options.set_preference('dom.webnotifications.enabled', False)
options.set_preference('media.volume_scale', '0.0')
driver = webdriver.Firefox(executable_path=os.path.abspath(".") + '/geckodriver', options=options, service_log_path="geckodriver.log")
# Временой интервал ожидания
# Если в течении этого времени элемент НЕ найдется, то упадем с ошибкой
driver.implicitly_wait(20) # seconds
# Переходим на страницу
driver.get(url)
def write_text(text):
text = text.replace('c', 'с') # Замена на русскую С
text = text.replace('o', 'о') # Замена на русскую о
input_area = driver.find_element_by_id("inputtext")
# if driver.find_element_by_class_name("afterfocus").text == '.':
# input_area.send_keys(text + ".")
# else:
input_area.send_keys(text + " ")
def get_text():
a = driver.find_element_by_class_name("highlight")
return a.text
if __name__ == '__main__':
print("Жду начала игры")
input("Нажми enter")
while 1:
write_text(get_text())
# time.sleep(0.01)