Jump to content
UBot Underground

How to stop scrape when page element exists?


Recommended Posts

Hi,

 

I am scraping a page and I would like to stop when a particular elements appears on the page. May sound strange but as you scroll down the page additional content is automatically loaded on the page...

 

What I was thinking was I would loop until this condition is met.

 

Example:

 

start loop, ...scroll, scroll, scroll, check [condition not met]

...scroll, scroll, scroll, check [condition not met]

...scroll, scroll, scroll, check [condition not met]

...scroll, scroll, scroll, check [condition not met]

...scroll, scroll, scroll, check [condition not met]

...scroll, scroll, scroll, check [condition not met]

...scroll, scroll, scroll, check [CONDITION MET], stop loop.

 

The condition is a text element that basically reads, "end of page". 

 

Can you tell me how to add a loop command that will stop when this condition is met? 

 

Thanks for your help!

 

Link to post
Share on other sites

There is a UBS command: wait for element that you can use - it has either "Appear" or "Disappear" in Advanced options.

Link to post
Share on other sites

Hi VaultBoss,

 

Thanks, but I'm not sure if this command will help. If I enter a wait for element command into a loop and that condition is not met my loop breaks on the first cycle. I need my loop to continue until a condition is met.

 

I could definitely be off with this... If I am, please let me know how adding this command works in the situation outlined above.

 

Thanks!

Link to post
Share on other sites

You can use a LOOP WHILE command node and place your loop exit condition there...

 

LOOP WHILE($exists(~~~~Element to look for here~~~~)) {
}

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...