I am trying to auto-scroll the webpage for this link for a custom date range. After scrolling, I have to save the full HTML of the page manually.
At first, I am choosing a custom range ( example 1-7 July 2022
), as shown below.
Now, I am trying to auto-scroll this page using Console
. For this, I am using setInterval function like this way,
var button=document.getElementById("paginationShowMoreText");
myTimer = setInterval(function(){
button.click();
}, 1000);
Then after a minute clearInterval(myTimer);
to terminate setInterval
. After running this in console, I expect that it would show all analysis between custom range.But, unfortunately, it gives me the repetition of 1st page. How can I get the entire scrolled page so that I can download the page as source? Is there any other way to auto-scroll for a certain range of data, any kind of suggestion would be helpful for me.
Thanks for your kind attention.
Try this
var button = document.getElementById("paginationShowMoreText");
setInterval(function(){
button.click();
window.scrollTo(0, document.body.scrollHeight);
}, 1000);
The answer of Vivek is almost correct, but you need to re-query the button as its onclick attribute is changed after each click. (I've modified the query to make it a bit more precise: it fetches the anchor link instead of it's label)
So this should work as intended:
setInterval(function(){
var button = document.querySelector('[data-action=listPaginationItems]');
if (button) button.click();
window.scrollTo(0, document.body.scrollHeight);
}, 1000);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.