如何点击链接并保持授权

时间:2017-06-29 13:19:10

标签: javascript phantomjs

我是如何在网站上授权的:

var webpage = require('webpage');
var page = webpage.create();

page.settings = {
    loadImages: false,
    javascriptEnabled: true,
    encoding: "utf8",
    userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36',
};

phantom.cookiesEnabled = true;

page.open("http://www.example.com/profile/Login.aspx", function(status) {
    if (status === "success") {
        page.evaluate(function() {
            document.getElementById("ctl00_ContentPlaceHolder1_tbUsername").value = "admin";
            document.getElementById("ctl00_ContentPlaceHolder1_tbPassword").value = "1234";
            document.getElementById("ctl00_ContentPlaceHolder1_btnLogin").click();
        });
        window.setTimeout(function() {
            console.log(page.url);
            phantom.exit();
        }, 2000);
    }
});

我现在如何关注该链接并保持授权? 问题是,当我登录并尝试转到另一个页面时,授权被重置,我无法获取数据

0 个答案:

没有答案