You are browsing a tutorial guide for the latest Octoparse version. If you are running an older version of Octoparse, we strongly recommend you upgrade because it is faster, easier, and more robust! Download and upgrade here if you haven't already done so!

Exit loop means to stop looping the elements. You can set up how many times you want a loop to repeat in a task. Exit loop is useful if you encounter the following scenarios:

  • You will find that the task keeps scraping the last page of data

  • You only want the first 10-page data

  • You only need the top 5 listing data

  • ......

This kind of problem can be solved with XPath if you have a bit of knowledge about HTML (What is XPath and how to use it in Octoparse). If you have no idea what it is, you can make use of the Exit loop feature.


Where do I find it?

It can be found at every Loop Item. Just click on Loop Item in the workflow to open the action settings and find the End Loop at the bottom of the settings.

Please note that "Pagination" is also a loop item.

5.png

How do I use it?

Case 1: When you're under a Pagination step, and you only need the data from the first 3 pages, you can tick the checkbox and enter "3" for the Repeats.

8.png

Case 2: If the current page has 15 listing items, but you only need the first 5 results, you can go to Loop Item which contains all the listings to enable the Exit loop feature.

7.png

During the extraction, the loop will stop if it reaches the number of repeats you enter for the Exit loop.

Did this answer your question?