3

I'm using website-scraper npm for scraper an website, https://github.com/website-scraper/node-website-scraper

I already got the Images from the website saved in assests folder. now I need to show the Images in a new dynamic html that this script need to create and to show this images. I saw this post: Create HTML file with JavaScript but its not seems to help.

How can I create an HTML using only JavaScript? create a real html File and save it locally. or should I use Nodejs? pass the images to server side and to attach the images to a hbs? Other options?

John doe
  • 317
  • 3
  • 5
  • 15

1 Answers1

10

You could use filesystem API to write anything you want to any file. You would create an HTML string using any method you want (string concatenation for example or using Underscore.js templates) and then write it to any file using the Node.js filesystem API.

var fs = require('fs');

var htmlContent = '<html>Whatever</html>';

fs.writeFile('/my-page.html', htmlContent, (error) => { /* handle error */ });
ph0enix
  • 763
  • 2
  • 8
  • 23
Denis Pshenov
  • 11,157
  • 6
  • 42
  • 42