e.jahandar
e.jahandar

Reputation: 1763

Getting cookies saved by firefox with python

Is there any way to get cookies saved by Firefox with python code? I think its possible to interact with Firefox javascript interpreter with python but i don't know how.

Actually i need firefox to browse a Web page, the Web page has some sort of authentications and finaly it makes a session key cookie, I want know cookie value and of course automatically with python.

Upvotes: 0

Views: 1196

Answers (1)

alecxe
alecxe

Reputation: 473873

You can do it with selenium, fire up a browser, navigate to a page, make the desired actions on a page and then use get_cookies() to extract the cookies:

Returns a set of dictionaries, corresponding to cookies visible in the current session.

from selenium import webdriver 

driver = webdriver.Firefox()
driver.get("http://www.google.com")

# do something else if needed

print(driver.get_cookies())

You can even dump and load cookies if needed:

Upvotes: 1

Related Questions