Javascript PhantomJS在按钮单击事件后捕获下一页内容

Javascript PhantomJS在按钮单击事件后捕获下一页内容,javascript,node.js,phantomjs,headless-browser,Javascript,Node.js,Phantomjs,Headless Browser,我试图在单击方法之后捕获第二页内容。但它正在返回头版内容 const status = await page.open('https://www.dubailand.gov.ae/English/services/Eservices/Pages/Brokers.aspx'); console.log(status); await page.evaluate(function() { document.querySelector('#ctl00_ctl42_g_26779dcd_6f3a_

我试图在单击方法之后捕获第二页内容。但它正在返回头版内容

const status = await page.open('https://www.dubailand.gov.ae/English/services/Eservices/Pages/Brokers.aspx');
console.log(status);
await page.evaluate(function() {
    document.querySelector('#ctl00_ctl42_g_26779dcd_6f3a_42ae_903c_59dea61690e9_dpPager > a.NextPageLink').click();
})

const content = await page.property('content');
console.log(content);
我使用Puppeter完成了类似的任务,但由于Puppeter的部署问题,我转而使用phantomjs。
感谢您提供的任何帮助。

您将获得首页,因为您在单击“下一步”按钮后立即请求页面内容,但您需要等待Ajax请求完成。这可以通过观察a来实现:当它不可见时,结果显示为

// Utility function to pass time: await timeout(ms)
const timeout = ms => new Promise(resolve => setTimeout(resolve, ms));

// emulate a realistic client's screen size
await page.property('viewportSize', { width: 1280, height: 720 });

const status = await page.open('https://www.dubailand.gov.ae/English/services/Eservices/Pages/Brokers.aspx');

await page.evaluate(function() {
    document.querySelector('#ctl00_ctl42_g_26779dcd_6f3a_42ae_903c_59dea61690e9_dpPager > a.NextPageLink').click();
});

// Give it time to start request
await timeout(1000);

// Wait until the loader is gone
while(1 == await page.evaluate(function(){ 
    return jQuery(".Loader_large:visible").length 
}))
{
    await timeout(1000);
    console.log(".");
}

// Now for scraping
let contacts = await page.evaluate(function(){

    var contacts = []; 
    jQuery("#tbBrokers tr").each(function(i, row){
        contacts.push({"title" : jQuery(row).find("td:nth-child(2)").text().trim(), "phone" : jQuery(row).find("td:nth-child(4)").text().trim() })
    })

    return contacts;
});

console.log(contacts);

只是尝试了一些事情。page.evaluate中的代码不工作。意味着它不会进入page.evaluate的内部