Quantcast
Channel: Active questions tagged feed - Stack Overflow
Viewing all articles
Browse latest Browse all 547

In JavaScript, how to determine if you are at the end of a feed (like some pages on Facebook or Quora)?

$
0
0

You can jump to the end of a webpage using JavaScript like this

window.scrollTo(0, document.body.scrollHeight);

but nowadays it is common that pages load more content when you reach the end. Two examples of such pages are https://www.facebook.com/friends/list and https.//www.quora.com

Let's say you run the oneliner above in a loop to reach the end of a page that behaves like this, how can you detect that you have reached the end? That is, no more content will be loaded.

I'm scraping a web page so I am looping something like the oneliner above to get to the end but I don't know when I have reached it. An important detail to take into consideration is that the page I am scrolling down is VERY long and, after scrolling down and loading new content for a while it starts to slow down the browser. If loading new content in the beginning might take 1-2 seconds, it can, after scrolling down for a while, take 10-20 seconds (and that is why I am scraping it - I am extracting the data to a CSV to be able to scroll through it faster instead of having to wait, if I would scroll manually, for the page load more content 50-100 times before I reach the end).


Viewing all articles
Browse latest Browse all 547

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>