Standard Loop

Standard loop is used to append new rows to your table.

Suitable for

  • Saving new data - example: scraping a list of profiles from a public website.

  • Performing static actions - example: repeatedly pressing keyboard tab key.

Key characteristics

  • Creates new rows in your table. Creates means appends.

  • Can manipulate the data in the rows that are appended during the loop. For example, you can add building blocks like Format Data to transform the format of the data that you are saving. Whatever actions your TaskBot takes during a loop iteration, they will all be applied to the same to-be-appended row.

  • Ignores any existing data in your tables. If you need to refer to the existing data, use variables, which are loop-independent (or, if applicable, select dynamic loop type, see Dynamic Loop).

  • Automatically scrolls if the data is displayed in an endless scroll (unless you select auto-detect option, see here: Auto-Detect Option!).

Example set-up

See Save Lists (link includes video tutorial).

How to Use Loop Index Syntax to Save Lists of Public Data

Once you review the example above (here is the same link again: Save Lists), you will see that the list selector contains {loop_index,1}, so that TaskBot can iterate over items in the list.

Selectors of items in a list contain a number by which they increment, as described here: Lists: Incremental CSS Selectors. In place of that number, you need to insert {loop_index,1}. Same principle applies both to CSS and XPath selectors.

Here is how to do that.

Step 1: Simply copy two to three selectors from the list you want to save. As an example, consider these are the first two selectors from the list that you copied.

Original:

  • 1st result in the list: main#main li:nth-child(1) > div.abi-saved-contacts-row__details > button[type='button'] > div > div > span

  • 2nd result in the list: main#main li:nth-child(2) > div.abi-saved-contacts-row__details > button[type='button'] > div > div > span

  • 3rd result in the list: main#main li:nth-child(3) > div.abi-saved-contacts-row__details > button[type='button'] > div > div > span

Notice how all the selectors in the list will display an incremental number (highlighted in red above).

Step 2: Substitute the incremental number by loop index.

main#main li:nth-child({loop_index,1}) > div.abi-saved-contacts-row__details > button[type='button'] > div > div > span

Alternative way if you don't know where exactly the increment takes place:

main#main li:nth-child(1) > div.abi-saved-contacts-row__details > button[type='button'] > div > div > span >> nth={loop_index,0}

In this case, we are using a filter (>>), as described here: Combine Filters with Standard CSS Logic.

In both scenarios, the number after the comma (1 in the first example and 0 in the second example) represents the first item in the list. To clarify: the nth-child() method starts count from 1, whereas >> nth= method starts count from 0 (0 corresponds to the 1st element in the list, 1 to the 2nd, etc.)

Special case: Skip items

In rare cases, a list might skip some numbers. For example, consider this list:

  • 1st result in the list: main#main li:nth-child(1) > div.abi-saved-contacts-row__details > button[type=“button“] > div > div > span

  • 2nd result in the list: main#main li:nth-child(3) > div.abi-saved-contacts-row__details > button[type=“button“] > div > div > span

  • 3rd result in the list: main#main li:nth-child(5) > div.abi-saved-contacts-row__details > button[type=“button“] > div > div > span

In this case, you can use this syntax: {loop_index,1,2}, where the additional number (in this case it's 2) means that two elements should be always skipped when incrementing the loop index.

Last updated