Last active
December 25, 2017 07:11
-
-
Save parsibox/5d690b4239e848afa253b529fab1a7a2 to your computer and use it in GitHub Desktop.
node js take screenshot whole page size
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const express = require('express') | |
const bodyParser = require('body-parser') | |
var webshot = require('/root/node-webshot/lib/webshot') | |
var options = { shotSize: { height: 'all' } , renderDelay : 500 , quality : 75 }; | |
const app = express() | |
app.use(bodyParser.urlencoded({ extended: false })) | |
app.use('/images', express.static(__dirname + '/images')) | |
app.post('/web', function (req, res) { | |
const myurl = req.body.myurl ; | |
const mytitle = req.body.mytitle; | |
webshot( myurl, '/root/node-webshot/webscreen/images/'+mytitle+'.png' , options, function(err) { | |
if( err){ | |
console.log(`error: ${err}`); | |
} | |
}); | |
res.set('Content-Type', 'text/plain'); | |
res.send(`You sent: ${myurl} to Express`); | |
}) | |
app.listen(8080, function (err) { | |
if (err) { | |
throw err | |
} | |
console.log('Server started on port 8080') | |
}) |
first install https://github.com/brenden/node-webshot
thene install npm install express body-parser
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
node webscreen.js
curl --data "myurl=mohsendavari.ir&mytitle=mohsen" localhost:8080/web
localhost:8080/images/mohsen.png