-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get to the "bottom" of an infinite scroll page? #625
Comments
It looks like maybe you are trying to call nightmare functions from within Also, unless the page specifically does something special when the page scrolls, scrolling the page isn’t going to make the result of |
The selector that I use in exists() is available until no further scrolling down is possible. On a sidenote, I have a different ideea. There are pages where you can't figure out very easily how the infinite scroll is implemented, or which is the selector, at least if you are a beginner like me. I want it to scroll down until the size of the returned document does not increase anymore. Javascript kills me, in Perl this would have been so easy, but Mechanize::Firefox is outdated and very slow. |
Another nit: your initial example also will only scroll until the page is 100000 px long, which is big, but "infinite" scroll pages could be longer.
This is a very naive method to answer your question: var Nightmare = require('nightmare');
var vo = require('vo');
var nightmare = Nightmare({
show: true
});
var run = function * () {
yield nightmare.goto('http://someInfiniteScrollPage.tld');
var previousHeight, currentHeight=0;
while(previousHeight !== currentHeight) {
previousHeight = currentHeight;
var currentHeight = yield nightmare.evaluate(function() {
return document.body.scrollHeight;
});
yield nightmare.scrollTo(currentHeight, 0)
.wait(3000);
}
yield nightmare.end();
};
vo(run)(function(err) {
console.dir(err);
console.log('done');
}); This approach has problems: when you're going against a page that actually is an infinite scroll, the above will never end. Also, the
If Perl is your language of choice, you might want to check out Selenium. I haven't personally tried it, but there is a Perl port of the remote driver. |
The text was updated successfully, but these errors were encountered: