F
F
FlashDoc2020-06-17 03:13:13
Python
FlashDoc, 2020-06-17 03:13:13

Python Selenium is it possible to work with one profile?

Hello, can you please tell me if it is possible to use one profile for webDriver selenium?.
The story is this: I am authorized on the site and use selenium to automate actions, but every time I start webdriver, the site recognizes me as an unconfirmed account user (that is, as if I didn’t log in, but maybe I was hacked, a new device, etc.). If you confirm in the account that it's me, then it works until the webDriver is restarted.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Web Dentist, 2020-06-17
@FlashDoc

We save the session.

import pickle
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://www.quora.com')
# login code
pickle.dump(driver.get_cookies() , open("QuoraCookies.pkl","wb"))

Add it next time you use it
import pickle
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://www.quora.com')
for cookie in pickle.load(open("QuoraCookies.pkl", "rb")):
    driver.add_cookie(cookie)

Source

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question