- run
npm install phantomjs-prebuilt
inside the directory where these files are located (launch.js and webpageRecord.js). - run
node launch.js
- See
frames
folder for images.
Created
July 14, 2019 17:05
-
-
Save moeiscool/c08ce68fccfd3a5fd3d8cac42a31bd9d to your computer and use it in GitHub Desktop.
Extract Frames from website as PNG images with PhantomJS
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
var fs = require('fs') | |
var path = require('path') | |
var childProcess = require('child_process') | |
var phantomjs = require('phantomjs-prebuilt') | |
var binPath = phantomjs.path | |
var childArgs = [path.join(__dirname, 'webpageRecord.js')] | |
var process = childProcess.spawn(binPath, childArgs) | |
var frame = 0 | |
process.stdout.on('data',function(data){ | |
console.log(data.toString()) | |
}) | |
// process.stderr.on('data',function(){ | |
// console.log(data.toString()) | |
// }) |
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
var page = require("webpage").create(); | |
page.viewportSize = { width: 1920, height: 1080 }; | |
page.open("https://www.accuweather.com/en/ca/vancouver/v6c/weather-forecast/53286", function() { | |
setTimeout(function() { | |
// Initial frame | |
var frame = 0; | |
// Add an interval every 25th second | |
setInterval(function() { | |
// Render an image with the frame name | |
page.render("frames/weather" + frame++ + ".png", { format: "png" }) | |
// Exit after 50 images | |
if (frame > 100) { | |
phantom.exit(); | |
} | |
}, 1000); | |
}, 666); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment