0

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.

e.jahandar
  • 1,715
  • 12
  • 30

1 Answers1

1

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:

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195