Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
412 views
in Technique[技术] by (71.8m points)

javascript - 我想要“获取”请求,直到整个网站组件加载,然后再获取页面的HTML。(I want, “fetch” request to wait until the whole website components to load before fetching the HTML of page [closed])

I want, "fetch" request to wait until the whole website components to load before fetching the HTML of the page.

(我想要“获取”请求,直到整个网站组件加载后,再获取页面的HTML。)

right now it's only loading the minimal data of a website its not waiting until the website to load.

(现在,它仅加载网站的最少数据,而没有等到网站加载。)

var express = require('express');
var app = express();
const fetch = require("node-fetch");
const pdf = require("html-pdf");

app.post('/hello', async (req, res) => {
    let html = [];

     //FETCHING HTML DATA.
    await fetch("https://vuetifyjs.com/en/introduction/long-term-support")
    .then(resp => resp.text())
    .then(body => html.push(body))
    //CONVERTING HTML TO PDF
    pdf.create(html.toString()).toStream(function(err, stream){
       if (err) return res.send(err);
       res.type('pdf');
       stream.pipe(res);
    });
});

app.listen(3000, () => {
  console.log(`serving on port number 3000`)
});
  ask by CHROMOSOME translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...