Last active
June 1, 2018 17:10
-
-
Save jmsdnns/f73921dcaf8cdd3ce570b7dcc669c6a2 to your computer and use it in GitHub Desktop.
PhantomJS code for scrolling to the end of a Twitter timeline
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'), | |
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