NodeJS's screenshot of the phantomJS website how to wait for the web script to finish? (for example, data obtained by js performing ajax)

< H2 > problem description < / H2 >

now I"m going to take a screenshot of the website .

but I found that the screenshot shows a picture of the unexecuted page script JS. I have seen a lot of documents and netizens" answers, but my search ability is a little poor, and I can"t find the corresponding solution to the problem.

for example, this page has a list of data obtained by several XHR types. how can I take a screenshot after the page fully loads and executes JS?

here is my code

const phantom = require("phantom");

let count = 0;

(async function () {
  const instance = await phantom.create();
  const page = await instance.createPage();
  const status = await page.open("http://wenshu.court.gov.cn/list/list/?sorttype=1&number=TMSVETRT&guid=31e005b5-868f-ae69cf1d-c65e96bcf639&conditions=searchWord+%E5%BD%93%E4%BA%8B%E4%BA%BAPP+%E5%BD%93%E4%BA%8B%E4%BA%BA:%E5%BA%84%E6%9C%9D%E6%99%96");
  await page.evaluate(function() { // 
    return document.body.innerHTML;
  }).then(function(html){
    console.log(html);
  });
  if (status == "success") {
     await page.render("./lalal.png");
  }
  await instance.exit();
})();



use puppeteer .

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('http://wenshu.court.gov.cn/list/list/?sorttype=1&number=TMSVETRT&guid=31e005b5-868f-ae69cf1d-c65e96bcf639&conditions=searchWord+%E5%BD%93%E4%BA%8B%E4%BA%BAPP+%E5%BD%93%E4%BA%8B%E4%BA%BA:%E5%BA%84%E6%9C%9D%E6%99%96');
  await page.screenshot({path: 'example.png'});

  await browser.close();
})();

Don't use phantomjs. Now that chrome supports headless, the authors of p say they don't recommend it.
puppeteer and selenium have many choices.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31b31-2bd9a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31b31-2bd9a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?