首页 > 解决方案 > CasperJS 已被重定向,然后以 status=fail (HTTP 302) 退出

问题描述

/opt/casperjs 中的 CasperJS 版本 1.1.4,使用 phantomjs 版本 2.1.1。在centOS上运行。

试图通过在 ASP.net webforms 上运行的身份验证页面,但在提交按钮后单击:

casper.then(function(){
if (this.exists("#LoginTyreLink_LoginButton")) {
    this.echo("Login button found");
    this.click("#LoginTyreLink_LoginButton", function(){
        saveShot("login_button_clicked");
    });
}
});

我得到重定向周期和超时:

[debug] [phantom] Mouse event 'mouseup' on selector: #Loginsite_LoginButton
[debug] [phantom] Mouse event 'click' on selector: #Loginsite_LoginButton
[info] [phantom] Step anonymous 14/17: done in 3131ms.
[info] [phantom] Step _step 15/17 https://site.brand.eu/link/ (HTTP 200)
[info] [phantom] Step _step 15/17: done in 3155ms.
[debug] [phantom] Navigation requested: url=https://site.brand.eu/link/Homepage.aspx, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] Navigation requested: url=https://site.brand.eu/link/Login.aspx, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] Navigation requested: url=https://site.brand.eu/link//Homepage.aspx, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] Navigation requested: url=https://site.brand.eu/link/Login.aspx, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] Navigation requested: url=https://site.brand.eu/link/Homepage.aspx, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] Navigation requested: url=https://site.brand.eu/link/Login.aspx, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] Navigation requested: url=https://site.brand.eu/link/Homepage.aspx, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] Navigation requested: url=https://site.brand.eu/link/Login.aspx, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] Navigation requested: url=https://site.brand.eu/link/Homepage.aspx, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] Navigation requested: url=https://site.brand.eu/link/Login.aspx, type=Other, willNavigate=true, isMainFrame=true
[warning] [phantom] Loading resource failed with status=fail (HTTP 302): https://site.brand.eu/link/Login.aspx
[debug] [phantom] Automatically injected includes/jquery-3.3.1.js client side
[warning] [phantom] Casper.waitFor() timeout
[error] [phantom] Wait timeout of 20000ms expired, exiting.
Wait timeout of 20000ms expired, exiting.
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "about:blank"

我试图在我的本地机器上运行脚本 - 它成功了,但不能在我的远程 centOS 机器上运行。

附言

用了一年多就好了...

标签: node.jsweb-scrapingcentosphantomjscasperjs

解决方案


正如我上面提到的——平台是centOS。这很有趣,但是...

sudo yum update

然后:

sudo reboot

任务完成。


推荐阅读