Extractors: Lists & Loops
  • 05 Nov 2024
  • 1 Minute to read
  • Contributors
  • Dark
    Light
  • PDF

Extractors: Lists & Loops

  • Dark
    Light
  • PDF

Article summary

This article explains how to build Extractor robots for pages that contain lists of items, e.g., product listing pages.

To learn the basics of how to build Extractor robots, please see Extractors.

To process a list of items on a page, use the step type Loop through elements:

e1.png

To add the step, select one of the items (elements) on the page and select Add [x] suggestions to selection in the right-hand menu that pops up:

e2.png

Now select Loop through elements:

e3.png

The loop step has now been added to the robot:

e4.png

Selecting the step forward button increments the counter in the step itself (for now, ignore the No output available error: we will handle that below):

e5.png

Loop through elements

The robot we have built above just loops through the elements on the page. It doesn't interact with them in any way, e.g., select them or extract the image.

Let's implement a robot that selects each image, and, on the product details page, extracts the title, price and image.
Follow the steps below:

  1. Ensure that the robot is stepped inside the loop:

e6.png

  1. In the right-hand menu, select Click element:

e7.png

The robot has now navigated to the details page of the element it selected and the selecting of the image is visible in the loop.

  1. To extract the title, in the right-hand menu select Extract from element:

e8.png

  1. Enter a name in the output field, e.g., title, and select Ok:

e9.png

  1. On the Results tab, you can verify that the title has been correctly extracted:

e10.png

  1. Go back to the Steps tab and repeat the process for the price and the image. The robot should now look like this:

e11.png

Tip!

To learn how to remove the $ symbol to convert the price into a number instead of a text, see the How do I format my output? section of What should I know about input and output?

  1. Select step forward to verify that the robot correctly loops through the details pages and extracts the values:

e12.png

  1. When you are happy with the robot, save it.

The robot is now ready to be configured and executed to get the full results, as described in the Executing the Robot: Getting Results section of Extractors.

And voilĂ , that's it. Enjoy your loopy robot!

More on Extractors

To learn about branches and how Extractors navigate pages, see The extractor editor and Site navigation


Was this article helpful?