无法在queryselector中打开多个页面。在新窗口中打开链接时单击phantomjs(目标=_空白) 第二页无法在phantomjs中读取——我的代码如下 var webPage=require('webPage') var page=webPage.create() page.onLoadFinished=函数(){ var title=page.evaluate(函数() { 返回文档.querySelector(#link1”).innerText; }); console.log(标题); 第页评估(函数(参数) { document.querySelector(“#link1”)。单击(); }); page.onLoadFinished=函数(){ var title1=page.evaluate(函数() { 返回文档.querySelector(#div1”).innerText; }); console.log(标题1); phantom.exit(); }; }; 第页打开('http://staging.eubookingsdata.com/scrape1.php,函数(状态){ }); 这里的第一页是“http://staging.eubookingsdata.com/scrape1.php" 我想在“中阅读div的内容”http://staging.eubookingsdata.com/scrape2.php" 一切正常,但当我在scrape1.php“link”中添加target=“\u blank”时,它停止了工作。 scrape1.php scrape2.php 你好,世界

无法在queryselector中打开多个页面。在新窗口中打开链接时单击phantomjs(目标=_空白) 第二页无法在phantomjs中读取——我的代码如下 var webPage=require('webPage') var page=webPage.create() page.onLoadFinished=函数(){ var title=page.evaluate(函数() { 返回文档.querySelector(#link1”).innerText; }); console.log(标题); 第页评估(函数(参数) { document.querySelector(“#link1”)。单击(); }); page.onLoadFinished=函数(){ var title1=page.evaluate(函数() { 返回文档.querySelector(#div1”).innerText; }); console.log(标题1); phantom.exit(); }; }; 第页打开('http://staging.eubookingsdata.com/scrape1.php,函数(状态){ }); 这里的第一页是“http://staging.eubookingsdata.com/scrape1.php" 我想在“中阅读div的内容”http://staging.eubookingsdata.com/scrape2.php" 一切正常,但当我在scrape1.php“link”中添加target=“\u blank”时,它停止了工作。 scrape1.php scrape2.php 你好,世界,phantomjs,Phantomjs,var webPage=require('webPage') var page=webPage.create() page.onLoadFinished=function()//第一级 { var title=page.evaluate(函数() { 返回文档.querySelector(#link1”).innerText; }); console.log(标题);//第一级 //var newPage=webPage.create(); //var page1=page.pages

var webPage=require('webPage')
var page=webPage.create()
page.onLoadFinished=function()//第一级

{

var title=page.evaluate(函数()
{
返回文档.querySelector(#link1”).innerText;
});
console.log(标题);//第一级



//var newPage=webPage.create();
//var page1=page.pages[0];

page.evaluate(函数(参数){//1级

document.querySelector(“#link1”)。单击();

});


};
page.onPageCreated=函数(newPage){
newPage.onLoadFinished=功能(状态){//2级
console.log(状态);
var title1=newPage.evaluate(函数()
{
返回文档.querySelector(#div1”).innerText;
});
console.log(标题1);//第二级
phantom.exit();
};
};
页面打开(“”,功能(状态)

{
console.log(“第1页”);

});

The second page cannot be read in phantomjs --my code is below var webPage = require('webpage');
var page = webPage.create();
page.onLoadFinished = function(){

var title = page.evaluate(function()
{
return document.querySelector("#link1").innerText;
});
console.log(title);

page.evaluate(function(args)
{
document.querySelector("#link1").click();

});

page.onLoadFinished = function(){

var title1 = page.evaluate(function()
{
return document.querySelector("#div1").innerText;
});
console.log(title1);
phantom.exit();
};
};

page.open('http://staging.eubookingsdata.com/scrape1.php', function(status) {

});
Here the first page is "http://staging.eubookingsdata.com/scrape1.php" I want to read the content of div in "http://staging.eubookingsdata.com/scrape2.php" Every thing is working fine ,but when i add target="_blank" in scrape1.php "link" it stopped working. scrape1.php <html>
<body>
<a id="link1" name="link1" href="scrape2.php" target="_blank" >click</a>
</body>
</html> scrape2.php <html>
<body>

<div id="div1" name="div1">hello world</div>
</body>

</html>