У меня проблемы с добавлением более 1 файла cookie в запрос, это мой javascript для 1 файла cookie:
var page = require('webpage').create();
phantom.addCookie({
'name' : 'TestCookie_Name_201312174009', /* required property */
'value' : 'TestCookie_Value_164009', /* required property */
'domain' : 'www.miau.com', /* required property */
'path' : '/',
'httponly' : true,
'secure' : false,
'expires' : (new Date()).getTime() + (1000 * 60 * 60) /* <-- expires in 1 hour */
});
page.open('http://www.miau.com', function() {
setTimeout(function() {
//page.render('google.png');
phantom.exit();
}, 200);
});
И я запускаю его через прокси, чтобы увидеть запрос:
phantomjs --ignore-ssl-errors=true --disk-cache=true --proxy=http://127.0.0.1:8080 --web-security=false test.js
Cookie добавляется нормально, но потом я пробую 2 куки:
И это не работает, я также попробовал этот другой вариант, рассматривая его как список
var page = require('webpage').create();
phantom.addCookie([{
'name' : 'TestCookie_Name_201312174009', /* required property */
'value' : 'TestCookie_Value_164009', /* required property */
'domain' : 'www.miau.com', /* required property */
'path' : '/',
'httponly' : true,
'secure' : false,
'expires' : (new Date()).getTime() + (1000 * 60 * 60) /* <-- expires in 1 hour */
}
,
{
'name' : 'TestCookie_Name_2', /* required property */
'value' : 'TestCookie_Value_2', /* required property */
'domain' : 'www.miau.com', /* required property */
'path' : '/',
'httponly' : true,
'secure' : false,
'expires' : (new Date()).getTime() + (1000 * 60 * 60) /* <-- expires in 1 hour */
}]);
Но, опять же, мне не удается заставить его работать ...
Еще одна вещь, которую я пробовал, это:
var page = require('webpage').create();
phantom.addCookie({
'name' : 'TestCookie_Name_201312174009', /* required property */
'value' : 'TestCookie_Value_164009', /* required property */
'domain' : 'www.miau.com', /* required property */
'path' : '/',
'httponly' : true,
'secure' : false,
'expires' : (new Date()).getTime() + (1000 * 60 * 60) /* <-- expires in 1 hour */
});
phantom.addCookie({
'name' : 'TestCookie_Name_2', /* required property */
'value' : 'TestCookie_Value_2', /* required property */
'domain' : 'www.miau.com', /* required property */
'path' : '/',
'httponly' : true,
'secure' : false,
'expires' : (new Date()).getTime() + (1000 * 60 * 60) /* <-- expires in 1 hour */
});
page.open('http://www.miau.com', function() {
setTimeout(function() {
//page.render('google.png');
phantom.exit();
}, 200);
});