Way Scroll Element Inside Page?

Questions & Answers about Helium Scraper 3
Post Reply
npg
Posts: 1
Joined: Thu Jun 04, 2020 8:06 pm

Way Scroll Element Inside Page?

Post by npg » Sat Jun 13, 2020 4:01 am

I have a table that's scrollable inside another page (also scrollable). I need to scroll the table all the way down in order to have it load all the data I'm trying to grab but I can't get any of the current tools to work.

ScrollToBottom only works on the page and doesn't scroll the table element at all. Infinite scroll seems to work but then when I check the data it's just grabbed the same 15 table rows over and over. It seems to reload the page, which resets everything.

What I think I need is a script something like this:

Code: Select all

function scrollDiv() {
  var elmnt = document.getElementById("ap-container");
  var ht = elmnt.scrollHeight;
  elmnt.scrollTop = ht;
}
that I can run on the page after it loads but I'm not sure how to use the scripting to make that work.

webmaster
Site Admin
Posts: 521
Joined: Mon Dec 06, 2010 8:39 am
Contact:

Re: Way Scroll Element Inside Page?

Post by webmaster » Sat Jun 13, 2020 5:10 pm

All scrolling functions scroll the currently selected element, which defaults to the whole page. So if you select the scrollable element it will scroll that element instead of the whole page:

Code: Select all

Select.ScrollableElement
InfiniteScroll
   ·  Select.ListItem
   ·  1000
   ·  true
To select the scrollable element, just select any element inside and press the Select Parent button in the selection panel (you may need to press the Expand button at the bottom right corner first) until the scroll bar is included in the selection.

Note that the sample above will select each list item, so below that action you'd put whatever actions extract from each individual item inside the scrollable element (see here for example). This is usually better than loading all the contents at once, since there can be millions of items which could end up crashing the browser.

If there are not so many items to load, you can still load them all before running any other actions like this:

Code: Select all

Sequence.Last
   ·  Sequence.Take
         ·  10
         ·  Sequence.Do
               ·  Select.ScrollableElement
                  Browser.ScrollToBottom
Just replace the number 10 with the number of times you want the scroll to run.

If you're still having trouble please send the URL and I'll take a look at it.
Juan Soldi
The Helium Scraper Team

Post Reply