github.com/MontFerret/ferret@v0.18.0/examples/lazy-loading.fql (about)

     1  LET doc = DOCUMENT('https://soundcloud.com/charts/top', { driver: "cdp" })
     2  
     3  LET endSelector = ''
     4  LET listSelector = '.chartTracks ul'
     5  
     6  WAIT_ELEMENT(doc, listSelector)
     7  
     8  LET list = ELEMENT(doc, listSelector)
     9  LET initialCount = ELEMENTS_COUNT(list, 'li')
    10  LET lastItem = 50
    11  
    12  LET preload = (
    13      FOR i DO WHILE !ELEMENT_EXISTS(doc, '.chartTracksEnd')
    14          LET initial = i > 0 ? SCROLL_BOTTOM(doc) && WAIT(500) && SCROLL_TOP(doc) && false : true
    15  
    16          RETURN NONE
    17  )
    18  
    19  WAIT_ELEMENT(list, FMT('li:nth-child({})', lastItem))
    20  
    21  FOR track, i IN ELEMENTS(list, 'li')
    22      RETURN {
    23          num: i + 1,
    24          artist: TRIM(INNER_TEXT(track, '.chartTrack__details .chartTrack__username')),
    25          track: TRIM(INNER_TEXT(track, '.chartTrack__details .chartTrack__title'))
    26      }
    27  
    28  
    29