Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Login Can';t使用casperjs登录才能工作_Login_Phantomjs_Casperjs_Login Script - Fatal编程技术网

Login Can';t使用casperjs登录才能工作

Login Can';t使用casperjs登录才能工作,login,phantomjs,casperjs,login-script,Login,Phantomjs,Casperjs,Login Script,我用casperjs把这个页面删除了一段时间。最近需要登录才能看到页面上的信息,我就是无法让它工作。我似乎找不到我必须单击哪个项目才能删除免责声明,然后才能登录到该网站。有两种不同的方法,这将起作用: var casper = require('casper').create({ verbose: true, logLevel: 'debug', waitTimeout: 5000, userAgent: 'Mozilla/5.0 (X11; Linux x86_

我用casperjs把这个页面删除了一段时间。最近需要登录才能看到页面上的信息,我就是无法让它工作。我似乎找不到我必须单击哪个项目才能删除免责声明,然后才能登录到该网站。

有两种不同的方法,这将起作用:

var casper = require('casper').create({
    verbose: true,
    logLevel: 'debug',
    waitTimeout: 5000,
    userAgent: 'Mozilla/5.0 (X11; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0',
    viewportSize:{width: 1600, height: 900}
});
casper
.on("error", function(msg){ this.echo("error: " + msg, "ERROR") })
.on("page.error", function(msg, trace){ this.echo("Page Error: " + msg, "ERROR") })
.on("remote.message", function(msg){ this.echo("Info: " + msg, "INFO") });

casper
    .start("https://www.wikifolio.com/de/de/home", function(){
    this.click('div.js-change-country-mode-btn');
    this.wait(500,function(){this.click('a.js-login-button')});
    this.wait(500,function(){
    this.fillSelectors('form[action$=login]', {
        "input#Username" : "luxadm1@gmail.com",
        "input#Password" : "<pass>"
    },true);
})
})
   .then(function(){
    this
.capture("Afterlogin.png")
.wait(5000,function(){ this.capture("Afterlogin2.png") })
   })
      .run();
var casper=require('casper')。创建({
没错,
日志级别:“调试”,
等待超时:5000,
用户代理:“Mozilla/5.0(X11;Linux x86_64;rv:49.0)Gecko/20100101 Firefox/49.0”,
视口大小:{宽度:1600,高度:900}
});
卡斯珀
.on(“error”,函数(msg){this.echo(“error:+msg,error”)})
.on(“page.error”,函数(msg,trace){this.echo(“page error:+msg,error”)})
.on(“remote.message”,函数(msg){this.echo(“Info:”+msg,“Info”)});
卡斯珀
.开始(“https://www.wikifolio.com/de/de/home“,函数(){
点击('div.js-change-country-mode-btn');
this.wait(500,function(){this.click('a.js-login-button')});
this.wait(500,函数(){
this.fillSelectors('form[action$=login]”{
“输入#用户名”:”luxadm1@gmail.com",
“输入密码”:”
},对);
})
})
.然后(函数(){
这
.capture(“Afterlogin.png”)
.wait(5000,函数(){this.capture(“Afterlogin2.png”)})
})
.run();
你可以用 而不是。
文件:
文件:

这也会起作用:
您可以使用cookie来完成此操作:

var casper = require('casper').create({
    verbose: true,
    logLevel: 'debug',
    waitTimeout: 5000,
    userAgent: 'Mozilla/5.0 (X11; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0',
    viewportSize:{width: 1600, height: 900}
});
casper
.on("error", function(msg){ this.echo("error: " + msg, "ERROR") })
.on("page.error", function(msg, trace){ this.echo("Page Error: " + msg, "ERROR") })
.on("remote.message", function(msg){ this.echo("Info: " + msg, "INFO") });

//for  www.wikifolio.com/de/de/home  auth
phantom.cookies = [{// an array of objects
  'name'     : 'theAuthCookie',
  'value'    : '<very long string>',
  'domain'   : 'www.wikifolio.com',
  'path'     : '/',
  'httponly' : false,
  'secure'   : true,
  'expires'  : (new Date()).getTime() + (1000 * 60 * 60 * 43800) //5 years
},{ 'name'     : 'DisclaimerCountryPopupV2',
  'value'    : 'de',
  'domain'   : 'www.wikifolio.com',
  'path'     : '/',
  'httponly' : false,
  'secure'   : true,
  'expires'  : (new Date()).getTime() + (1000 * 60 * 60 * 43800) }]

var target = "https://www.wikifolio.com/de/de/alle-wikifolios/suche#/?tags=aktde,akteur,aktusa,akthot,aktint,etf,fonds,anlagezert,hebel&media=true&private=true&assetmanager=true&theme=true&super=true&WithoutLeverageProductsOnly=true&languageOnly=true"

casper
    .start(target, function(){    })
   .then(function(){
    this
.capture("Afterlogin.png")
.wait(5000,function(){ this.capture("Afterlogin2.png") })
   })
      .run();
var casper=require('casper')。创建({
没错,
日志级别:“调试”,
等待超时:5000,
用户代理:“Mozilla/5.0(X11;Linux x86_64;rv:49.0)Gecko/20100101 Firefox/49.0”,
视口大小:{宽度:1600,高度:900}
});
卡斯珀
.on(“error”,函数(msg){this.echo(“error:+msg,error”)})
.on(“page.error”,函数(msg,trace){this.echo(“page error:+msg,error”)})
.on(“remote.message”,函数(msg){this.echo(“Info:”+msg,“Info”)});
//www.wikifolio.com/de/de/home auth
phantom.cookies=[{//对象数组
'name':'theAuthCookie',
“值”:“,
“域”:“www.wikifolio.com”,
“路径”:“/”,
“httponly”:false,
“安全”:正确,
“过期”:(新日期()).getTime()+(1000*60*60*43800)//5年
},{'name':'DisclaimerCountryPopupV2',
'value':'de',
“域”:“www.wikifolio.com”,
“路径”:“/”,
“httponly”:false,
“安全”:正确,
“expires':(新日期()).getTime()+(1000*60*60*43800)}]
变量目标=”https://www.wikifolio.com/de/de/alle-wikifolios/suche#/?tags=aktde,akteur,aktusa,akthot,aktint,etf,fonds,anlagezert,hebel&media=true&private=true&assetmanager=true&theme=true&super=true&WithingLeverageProductsOnly=true&languageOnly=true“
卡斯珀
.start(目标,函数(){})
.然后(函数(){
这
.capture(“Afterlogin.png”)
.wait(5000,函数(){this.capture(“Afterlogin2.png”)})
})
.run();

在第二个解决方案中,登录名在哪里?或者我必须附加登录名吗?我猜您的登录信息存储在authCookie的值中?