My First Playground

node v6.17.1
version: 2.0.0
endpointsharetweet
This is a playground to test JavaScript. It runs a completely standard copy of Node.js on a virtual server created just for you. Every one of npm’s 300,000+ packages are pre-installed, so try it out:
var util = require('util'); var glob = require("glob"); var express = require('express'); var scrape = require('website-scraper'); var path = require('path'); var router = express.Router(); var fs = require('fs-extra'); var archiver = require('archiver'); var beautify_js = require('js-beautify').js_beautify; var beautify_css = require('js-beautify').css; var beautify_html = require('js-beautify').html; var cheerio = require('cheerio');
var scrape = require('website-scraper'); var folder_name = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5); var folder = path.join('public', 'upload', folder_name); var zipfile = path.join('public', 'upload', folder_name + ".zip"); scrape({ urls: [ 'http://nodejs.org/', // Will be saved with default filename 'index.html' {url: 'http://nodejs.org/about', filename: 'about1.html'}, {url: 'http://blog.nodejs.org/', filename: 'blog.html'} ], directory: folder }).then(function(res){ var output = fs.createWriteStream(zipfile); var archive = archiver('zip'); output.on('close', function () { console.log(archive.pointer() / 1024 + ' total bytes'); console.log(folder_name + ".zip"); }); archive.on('error', function(err){ console.log(err); }); archive.pipe(output); archive.directory(folder, false); archive.finalize(); }).catch(console.log);
Loading…

no comments

    sign in to comment