Answer the question
In order to leave comments, you need to log in
selenium+telegram?
Hello everyone, I can't make the transition between def!
def driver(message):
today = datetime.datetime.today()
chat_id = message.chat.id
user_id = message.from_user.id
user = user_data[user_id]
myDates = today.strftime("%Y-%m-%d 00:00:00")
ersq = datetime.datetime.strptime(myDates, "%Y-%m-%d %H:%M:%S").timestamp()
ghsa = float(ersq) * 1000
url = "" % (
ghsa, user.time)
opts = Options()
opts.add_argument(
"user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36")
opts.add_argument("--user-data-dir=Users/Profile 1")
opts.add_argument("--profile-directory=Profile 1")
driver = webdriver.Chrome(options=opts)
driver.get(url)
time.sleep(15)
elem = driver.find_element_by_name("")
elem.send_keys(" ")
time.sleep(4)
pag.hotkey('ctrl', 'a')
time.sleep(4)
pag.hotkey('backspace')
time.sleep(4)
elem.send_keys()
time.sleep(4)
elem = driver.find_element_by_name("accountPassword")
elem.send_keys()
time.sleep(4)
elem = driver.find_element_by_id("continueFieldbutton").click()
elem = driver.find_element_by_id("send-code-to-trusted-device").click()
elem = driver.find_element_by_name("digit1")
msg = bot.send_message(chat_id, "Напиши код который тебе пришёл, у тебя есть 20сек.")
bot.register_next_step_handler(msg, third)
def third(message):
elem = driver.find_element_by_name("digit1")
text_code = message.text
time.sleep(4)
elem.send_keys(text_code)
time.sleep(4)
elem = driver.find_element_by_id("setupLink").click()
time.sleep(50)
pag.hotkey('ctrl', 'a')
time.sleep(4)
pag.hotkey('ctrl', 'c')
time.sleep(10)
driver.execute_script(
"window.open('')")
time.sleep(50)
pag.hotkey('delete')
time.sleep(40)
pag.hotkey('ctrl', 'w')
time.sleep(10)
driver.execute_script(
"window.open('')")
time.sleep(50)
pag.hotkey('ctrl', 'v')
time.sleep(30)
driver.quit()
Answer the question
In order to leave comments, you need to log in
Name the variable and the function differently, why the function is called the driver, like the variable
Well, you will need to pass the driver itself to the third function.
# ...
bot.register_next_step_handler(msg, third, driver)
# ...
# ...
def third(message, driver):
# ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question