Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
489 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 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...