pra*_*rma 6 javascript google-visualization node.js jsdom
我正在使用 jsdom 从服务器加载一个 html 页面,使用 nodejs 来获取一些谷歌图表图形 URL。但问题是我只能获取部分加载的图形 URL。如何让 jsdom 等到完整的图形呈现出来,然后在 console.log 中记录 URL。
下面是我的 JSDOM 代码:
router.post('/Endpoint',(req,res,next)=>{
// the file I will be loading
uri = 'one.html',
// the options that I will be giving to jsdom
options = {
runScripts: 'dangerously',
resources: "usable"
};
// load from an external file
jsdom.fromFile(uri, options).then(function (dom) {
let window = (new jsdom(``, { pretendToBeVisual: true })).window;
window.requestAnimationFrame(timestamp => {
console.log(timestamp > 0);
});
}).catch (function (e) {
console.log(e);
});
Run Code Online (Sandbox Code Playgroud)
});//EOF API
图 URL 是 base64 编码的字符串