- Print
- DarkLight
- PDF
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:
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:
Now select Loop through elements:
The loop step has now been added to the robot:
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):
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:
- Ensure that the robot is stepped inside the loop:
- In the right-hand menu, select Click element:
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.
- To extract the title, in the right-hand menu select Extract from element:
- Enter a name in the output field, e.g., title, and select Ok:
- On the Results tab, you can verify that the title has been correctly extracted:
- Go back to the Steps tab and repeat the process for the price and the image. The robot should now look like this:
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?
- Select step forward to verify that the robot correctly loops through the details pages and extracts the values:
- 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