简体   繁体   English

我如何遵循casperjs的网址

[英]how do i follow the url casperjs

here is my casperjs script below everything is working fine i just need help following a redirect 这是我的casperjs脚本,下面一切正常,我只需要重定向后的帮助

var casper = require('casper').create ({
    waitTimeout: 15000,
    stepTimeout: 15000,
    verbose: true,
    viewportSize: {
        width: 1280,
        height: 960
    },
    pageSettings: {
        "userAgent": 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.10 (KHTML, like Gecko) Chrome/23.0.1262.0 Safari/537.10',
        "webSecurityEnabled": false,
        "ignoreSslErrors": true
    },
    onWaitTimeout: function() {
      // casper.capture('./out/wait-timeout:_' + TimeTidy() + '.png');
      // throw newItem Error stuff;
    },
    onStepTimeout: function() {
      // casper.capture('./out/step-timeout' + TimeTidy() + '.png');
      // throw newItem Error stuff;
    }
});

// Vars
var fs  = require('fs');
var url = 'https://www.bt.com/wifi/secure/index.do?s_cid=con_FURL_btwifi';

// Start
casper.start();

casper.thenOpen(url, function() {
    // this.echo(this.getTitle());
    casper.click("a[href='http://www.bt.com/wifi/secure/status.do']");
    this.echo(this.getCurrentUrl());
});

// Wait 2 sec then write to txt file
casper.wait(9000, function() {
    this.echo(this.getHTML());
    this.echo(this.getCurrentUrl());
});

// Executes
casper.run();

how can i visit the last 我怎样才能参观最后一个

this.echo(this.getCurrentUrl());

and fill in a form if any one can help me on adding this function to my form i would be so happy 并填写表格,如果有人可以帮助我将此功能添加到表格中,我会很高兴

I'm not sure to truly understand what you want to do. 我不确定是否真正了解您想做什么。

Capser should follow redirections, so nothing to do. Capser应该遵循重定向,因此无所事事。

To fill the form just add a new step like this 要填写表格,只需添加一个新步骤,例如

casper.then(function () {
    casper.fill('form[name=LoginForm]', {
        'username':'YOURUSERNAME',
        'password':'YOURPASSWORD'
    }, true);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM