问题
Hi for me the command did not working:
$ casperjs --web-security=no --cookies-file=/tmp/mycookies.txt myscript.js
(just copied from the documentation of casperjs: http://docs.casperjs.org/en/latest/cli.html#casperjs-native-options)
I have created the cookie file from another script. Now I want to implement the cookies into the second script. But the above command did not work.
What I want, is to implement the cookies before the first page invoke.
And yes the cookies are still alive, bcause if I use this in the second script:
var fs = require('fs');
phantom.cookies = JSON.parse(fs.read("pathToTheCookies"));
it works. But I want to do it with the command line, because I want to give the path with arguments.
Thanks.
OS: Windows 10
Best regards.
rikku47
回答1:
I got it. My solution for Windows (my OS Windows 10) is a command line like this:
casperjs --cookies-file="""pathIncludeWhiteSpaces""" """scriptPathIncludeWhitspaces""" """argument1""" """argument2"""
In the arguments you can put paths too. Just wrape them with six quotes
"""AnyArgumentAndOrPath"""
and it should work. the official solution from the documentation did not work for me, if I use cookies.
With other word if I use this command:
casperjs --cookies-file=\"pathIncludeWhiteSpaces\" \"scriptPathIncludeWhitspaces\" \"argument1\" \"argument2\"
it work for the first time to write the cokkie file. But if I let it read, it do nothing (it looks like).
Here is the part of the documentation:
Hint
You may need to wrap an option containing a space with escaped double quotes in Windows. –foo=\”space bar\”
http://docs.casperjs.org/en/latest/cli.html#casperjs-native-options
Best regards rikku47
来源:https://stackoverflow.com/questions/45781604/casperjs-web-security-no-cookies-file-tmp-mycookies-txt-myscript-js-did-not