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


Groups > comp.lang.python > #88113

Save session Selenium PhantomJS

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <juan0christian@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.128
X-Spam-Level *
X-Spam-Evidence '*H*': 0.75; '*S*': 0.00; 'anymore.': 0.09; 'exit': 0.09; 'issue:': 0.09; 'measure': 0.09; 'multiples': 0.16; 'subject:session': 0.16; 'folder': 0.16; 'looked': 0.18; 'later': 0.20; 'thanks.': 0.20; 'driver': 0.24; 'script.': 0.24; 'tells': 0.24; 'login': 0.25; 'script': 0.25; 'code:': 0.26; 'tried': 0.27; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'work.': 0.31; 'code': 0.31; "skip:' 10": 0.31; 'doc': 0.31; 'could': 0.34; 'knows': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'google': 0.35; "didn't": 0.36; 'skip:o 20': 0.38; 'skip:& 10': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:c 50': 0.60; 'hope': 0.61; 'browser': 0.61; 'save': 0.62; 'temporary': 0.65; 'anything.': 0.68; 'skip:w 40': 0.68; 'default': 0.69; 'everything,': 0.84; 'execution.': 0.84; 'objective:': 0.84; 'skip:w 60': 0.84; 'subject:Save': 0.91; 'pc.': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=gt+/Fa846298peruILZgfJ5H6wsosc2sBXXRCPRmCBQ=; b=hqXxKHxGaZBVHesPYK4uSWE2ohzDZ9AQyPKAspOiidQAxNlEjFAVvvRQVvA0CuZQUO K2i09QwXCZe6KH+PSbieQwJ0GAs+f7iyQ+g7dj2S8olEVtyezCjYj2cAdGTDkRd2KSQR Fd+Iakowfbl8BFu/Ytxft8L4+aGermyX0VS6YsEzM9ZyvhzhrYG+ZT2PUrb513y6ltSi 5Hf6MnGWgbPO9Ae/0TlEvispGeyrh1RVIPe5nZnM0lxY+gxn1XQUd94HxV1V3Drl1cQa jN75UBnuVg3YtmOtNAAx+MUN6KsSi5Md7orOUAkQED7kVVtVZjiIma/7OWW9vQ7/cDc2 zBJA==
X-Received by 10.50.60.72 with SMTP id f8mr41373981igr.31.1427415343054; Thu, 26 Mar 2015 17:15:43 -0700 (PDT)
MIME-Version 1.0
From "Juan C." <juan0christian@gmail.com>
Date Fri, 27 Mar 2015 00:15:42 +0000
Subject Save session Selenium PhantomJS
To Python <python-list@python.org>
Content-Type multipart/alternative; boundary=047d7b10d0e378461c05123a083b
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.227.1427415352.10327.python-list@python.org> (permalink)
Lines 60
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1427415352 news.xs4all.nl 2831 [2001:888:2000:d::a6]:55635
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:88113

Show key headers only | 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