Jump to content
UBot Underground

Scraping elements from JavaScript/AJAX scrolled page


Recommended Posts

Hi, all.

 

I need to scrape results from a page, that load necessary elements on scrolling. I know the id of the element, that appears at the bottom of the page after several "scrolls", so it seems to me, that I should use "run javascript", "wait for an element" or "focus".

 

However, I've tried several receipts from this forum, but none of them worked.

 

In particular, I've tried the script 

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

which was suggested several times in this forum (here, here and here). It didn't help. I saw neither scrolling no parsed elements.

 

More sophisticated trick based on the same idea didn't work either. Here it is:

 

 

 

loop(100) {
wait(1)
run javascript("window.scrollBy(0,50); // horizontal and vertical scroll increments
scrolldelay = setTimeout(\'pageScroll()\',100); // scrolls every 100 milliseconds")
wait(1)

 

I've found a mention of a method scrollIntoView()from this comment on StackOverflow, but I'm not sure how to implement it in Ubot.

 

Can anyone help me?

Link to post
Share on other sites

This is the exact code I used in one of my bots:       (Just copy and paste it :) )

run javascript("window.scrollBy(0,500); // horizontal and vertical scroll increments
scrolldelay = setTimeout(\'pageScroll()\',100); // scrolls every 100 milliseconds")
Edited by ptrick125
  • Like 1
Link to post
Share on other sites

 

(Just copy and paste it  :) )

run javascript("window.scrollBy(0,500); // horizontal and vertical scroll increments

scrolldelay = setTimeout(\'pageScroll()\',100); // scrolls every 100 milliseconds"

)

 

I'm not sure, where to copy/paste that, so I've done it this way (see attachment):

 

post-11567-0-60734400-1379579069_thumb.png

 

An it still doesn't work  :(

 

Maybe I was following the advices about JavaScript wrong way all the time?  :unsure:

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...