Answer the question
In order to leave comments, you need to log in
How to convert cookie to QList
You need to convert the cookie to the QList < QNetworkCookie > format. I tried to pick up the structure of saving through regular expressions, but without result. Now I'm trying to save them through PhantomJS itself, I pass them to the script via the command line parameter in the form of JSON:
var needCookies = JSON.parse(require('system').args[1]);
for (key in needCookies) {
console.log(phantom.addCookie(needCookies[key]));
}
console.log(JSON.stringify(phantom.cookies, null, 2));
phantom.exit();
C:\phantomjs\phantomjs.exe --cookies-file=C:\server\www\lib3\get_content\_parser_lib\cCookie\cookies\testCookies-phantomjs.cookie --ignore-ssl-errors=true --load-images=true --local-storage-path=C:\server\www\lib3\get_content\_parser_lib\cPhantomJS\storage --output-encoding=utf-8 --local-to-remote-url-access=true 'C:\server\www\lib3\get_content\_parser_lib\cPhantomJS\script\addCookie.js' '^[^{^"name^":^"PHPSESSID^",^"value^":^"asdf123465^",^"domain^":^".test1.ru^",^"path^":^"^\/^",^"expires^":^"Wed, 22-Jan-14 05:58:58 GMT^",^"httponly^":false,^"secure^":false^},^{^"name^":^"testName^",^"value^":^"testValue^",^"domain^":^".test1.ru^",^"path^":^"^\/^",^"expires^":^"Wed, 22-Jan-14 05:58:58 GMT^",^"httponly^":false,^"secure^":false^}^]'
[General]
cookies="@Variant(\0\0\0\x7f\0\0\0\x16QList<QNetworkCookie>\0\0\0\0\x1\0\0\0\x4\0\0\0\x61logged_in=no; secure; HttpOnly; expires=Sat, 21-Jan-2034 01:18:06 GMT; domain=.github.com; path=/\0\0\0w__utma=1.138296252.1390267083.1390267083.1390267083.1; expires=Thu, 21-Jan-2016 01:18:02 GMT; domain=github.com; path=/\0\0\0Z__utmb=1.1.10.1390267083; expires=Tue, 21-Jan-2014 01:48:02 GMT; domain=github.com; path=/\0\0\0\x87__utmz=1.1390267083.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); expires=Tue, 22-Jul-2014 13:18:02 GMT; domain=github.com; path=/)"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question