Skip to content

Instantly share code, notes, and snippets.

@jmsdnns
Last active June 1, 2018 17:10
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmsdnns/f73921dcaf8cdd3ce570b7dcc669c6a2 to your computer and use it in GitHub Desktop.
Save jmsdnns/f73921dcaf8cdd3ce570b7dcc669c6a2 to your computer and use it in GitHub Desktop.
PhantomJS code for scrolling to the end of a Twitter timeline
var fs = require('fs'),
page = new WebPage(),
url = 'https://twitter.com/jmsdnns',
stepOffset = 0,
stepCounter = 0,
full_path = "/Users/jmsdnns/Projects/ghst/img-tw";
page.open(url);
page.onLoadFinished = function(status) {
if (status === 'success') {
window.setInterval(function() {
console.log("STEP " + stepCounter);
// Render image
var img_file_name = full_path + "/step" + stepCounter + ".png";
page.render(img_file_name);
console.log(" - step" + stepCounter + ".png");
console.log(" - size: " + fs.size(img_file_name));
console.log(" - step offset: " + stepOffset);
if (fs.size(img_file_name) < 100000) {
stepOffset = stepOffset - 1.5;
console.log(" - offset adjust: " + stepOffset);
}
stepOffset = stepOffset + 1;
stepCounter = stepCounter + 1;
page.scrollPosition = {
top: stepOffset * 500,
left: 0
};
}, 2000);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment