我发现(在SO上存在一些问题和疑问)phantom.js跨域cookie问题。
所以为了解决这个问题,我尝试下一次黑客攻击
.getCookies(function callback(result) {
var collectriumCookie = result.value[0];
appCookie = {
name : collectriumCookie.name,
domain: 'target.domain.com:5000',
value : collectriumCookie.value,
expiry : collectriumCookie.expire + 9999999
};
client.setCookie(appCookie);
})
.url('http://target.domain.com:5000/', function() {
client.setCookie(appCookie);
})
.url('http://target.domain.com:5000/', function() {
console.log(JSON.stringify(appCookie));
client.setCookie(appCookie);
client.getCookies(function(cookies) {
console.log(JSON.stringify(cookies))
});
})
我将cookie值存储在变量中并将其设置为目标子域(我尝试使用/不使用端口)
但是调试消息说:
{"name":"token","domain":"target.domain.com:5000","value":"2cb8f27ab0f0e19fe0f2076cde5bc82d5b6bb0ad148038a43c6945808e8210d64a2f062135f2bf59a580a4d3b9b207eda317aa3b413de951bd7d019feb5e1ec0","expiry":null}
{"sessionId":"f6e419ad-d848-423c-acd0-d7b153d0d64b","status":0,"state":"success","value":[{"name":"token","domain":".domain.com","secure":false,"path":"/","value":"","class":"org.openqa.selenium.Cookie","httpOnly":false,"hCode":110541305,"expiry":1428143377}],"class":"org.openqa.selenium.remote.Response","hCode":278799571}
cookie并不适用
为什么?
答案 0 :(得分:1)
我找不到答案。但使用PhantomJS v 2解决了跨域cookie的问题
目前编译时遇到一些麻烦,所以我花了大约5分钟来找到二进制文件