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: 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." Date: Fri, 27 Mar 2015 00:15:42 +0000 Subject: Save session Selenium PhantomJS To: Python 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 --047d7b10d0e378461c05123a083b Content-Type: text/plain; charset=UTF-8 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. --047d7b10d0e378461c05123a083b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Objective: Save the browser session/cookies to share them = in multiples script execution.

I currently have this working using C= hromeDriver:

chrome_options =3D Options()
chrome_options.add_argu= ment("user-data-dir=3D" + os.path.dirname(sys.argv[0]))
browse= r =3D webdriver.Chrome(chrome_options=3Dchrome_options)

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

Th= is way, I can login in the site I need once and exit the script. If I execu= te the script later everything is already saved and I don't have to log= in anymore.

I need this approach because the site has a security mea= sure where they send a key to my email everytime I login in a "new&quo= t; PC.


The issue: Now I need to use PhantomJS. I already tried t= his code:

cookie_path =3D os.path.join(os.getcwd(), 'cookie.txt&= #39;)
driver =3D webdriver.WebDriver(service_args=3D['--cookies-file= =3Dcookies.txt'])

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

=
Thanks.
--047d7b10d0e378461c05123a083b--