C
C
CryPack2020-08-16 13:25:04
Python
CryPack, 2020-08-16 13:25:04

On PythonAnywhere through Selenium is not authorized. Why?

Hello. There is this code:

browser.get('https://www.vk.com')
email = browser.find_element_by_id('index_email')
password = browser.find_element_by_id('index_pass')
login = browser.find_element_by_id("index_login_button")
time.sleep(2)
email.send_keys('login')
time.sleep(2)
password.send_keys('pass')
time.sleep(2)
password.send_keys(Keys.RETURN)
time.sleep(2)
browser.get('https://vk.com/im?sel=-166948584')
time.sleep(2)
msgs = browser.find_elements_by_class_name('_im_log_body')
msgs.reverse()
msg = msgs[0].text


He enters vk.com, logs in, enters a dialogue and looks for messages. Everything works locally, but it does not authorize on PythonAnywhere. With the help of browser.title, I learned that after the line password.send_keys(Keys.RETURN) remains on the authorization page. I tried instead of send_keys to look for the login button and click on it, but the result is the same. Please help, because I do not really understand why this is so.

PS The question can be considered closed, because. VK did not trust the IP of PythonAnywhere and a captcha popped up, which prevented me from logging in. Solved in this way:
options.add_argument(r"--user-data-dir=/путь/к/папке/с/профилями")
options.add_argument("--profile-directory=Название_папки_с_нужным_профилем")

More details if someone needs it: https://habr.com/en/post/442034/ ​​"

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question