Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #88113

Save session Selenium PhantomJS

From "Juan C." <juan0christian@gmail.com>
Date 2015-03-27 00:15 +0000
Subject Save session Selenium PhantomJS
Newsgroups comp.lang.python
Message-ID <mailman.227.1427415352.10327.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Objective: Save the browser session/cookies to share them in multiples
script execution.

I currently have this working using ChromeDriver:

chrome_options = Options()
chrome_options.add_argument("user-data-dir=" + os.path.dirname(sys.argv[0]))
browser = webdriver.Chrome(chrome_options=chrome_options)

This code tells Chrome to use a specific path, in my case the script path,
as "data" folder where it stores everything, and NOT use the default
approach where everything is temporary and deleted when the script exits.

This way, I can login in the site I need once and exit the script. If I
execute the script later everything is already saved and I don't have to
login anymore.

I need this approach because the site has a security measure where they
send a key to my email everytime I login in a "new" PC.


The issue: Now I need to use PhantomJS. I already tried this code:

cookie_path = os.path.join(os.getcwd(), 'cookie.txt')
driver = webdriver.WebDriver(service_args=['--cookies-file=cookies.txt'])

But it doesn't work. I looked at the PhantomJS doc and on Google but didn't
find anything. I hope someone knows better than me and could give me a
"hand" here.

Thanks.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Save session Selenium PhantomJS "Juan C." <juan0christian@gmail.com> - 2015-03-27 00:15 +0000

csiph-web