What is the “loop” button in the prompt window and how’s it work and why would i need it for my automation?

What is the “Loop” Button and How’s It Work?

Mastering Automation: A Step-by-Step Guide to Using the Loop Button

Automation is a game-changer when it comes to streamlining processes and saving time. In this blog post, we will walk you through the detailed steps of using the "Loop" button in an automation process, as demonstrated by our expert speaker.

Starting the Automation Process

To begin, the speaker starts a new recording without the need for cookies or Chrome profiles. Navigating to the targeted website, inquentra24.com, the speaker sets the stage for clicking and scraping details from each listing on the webpage.

Setting Up the Loop

The key to looping over elements on a page is the "Scrape List" step. By identifying and selecting the elements to loop over, the speaker ensures a systematic approach to scraping data effectively.

Iterating with the Loop Step

Adding a "Loop" step allows for iteration over the scraped elements. Connecting it to the "Scrape List" step sets the stage for running a series of actions for each element in the list.

Enhancing the Loop Automation

Within the loop, the speaker demonstrates the addition of click steps and scrape actions, highlighting the flexibility and power of automation tools like Task Magic. By defining scrape steps for various data points, the automation process becomes more robust and comprehensive.

Handling Navigation

A crucial aspect of the loop automation is handling navigation back to the original page after performing actions on each element. By incorporating a "Go Back" step, the speaker ensures a seamless flow of operations within the loop.

Wrapping Up the Automation

As the automation sequence nears completion, the speaker emphasizes the importance of reviewing and finalizing the steps. By confirming the scrape actions and ensuring all necessary data points are covered, the loop automation is set to run efficiently.

Observing the Loop in Action

To provide a visual representation, the speaker initiates the automation process, showcasing how each step unfolds in real-time. From scraping names to clicking on elements and navigating back, the loop automation demonstrates its effectiveness in handling repetitive tasks.



VIDEO TRANSCRIPT

So to use loop in an automation, I'm going to start a new recording. And then for this one, I don't need to use cookies or anything, any Chrome profiles, but if you needed to, you could click that yes, I am button and go through the cookie setup. Uh, my automation specifically is not going to need that. So I'm going to go to inquentra24.

com, which is the website that I'm scraping. Oh, that's the loom that I had open. Whoops. Let me edit that. Okay. Now we're at the website. I'm scraping. And what I want to do is I want to click each listing in here, and then I want to scrape some details from it before I go back and move on to the next one.

So to do this, what we first have to start with is a scrape list step, which is going to allow us to find all of the elements on the page we want to loop over. So I'll click the plus icon and then scrape a list. And then I'm going to click the first result. And then the second result, and we'll see that this found 15 items, which is how many are on the page.

Then I'll click confirm. Now, we're going to add a loop step, which is going to allow us to loop over all of the elements we just scraped. So I'll click on loop, and then continue anyways. And then for the loop item, I'm going to select the scrape list step that we have, so that we know which elements to loop over.

I'll close this really quick so we can see everything. Now what we have is a go to page step and maybe some other click steps to get to the page you need to. Then we scrape all of the elements on the page, the title right here. Now we have a loop step, which is going to allow us to run a bunch of steps for each element on this in this list.

Now, what I'm going to do is I'll record a click step inside of my loop by clicking this plus icon. We can see that it's indented just a little bit more since it's part of this loop and not the entire automation itself. Then I'm going to select click and I'll select the first title in this list. Now task magic will figure out that you want to iterate over all of these on the page from the elements that you scraped.

And when we click confirm here, that is all we need to do to tell task magic to loop over every single one on the page. The problem right now is, is because clicking this takes us somewhere We need to make sure that we can go back to that original page that we originally, um, that we had with all of the elements in the list.

So to do that, we have those options available after we save our automation. Before doing that, I'm going to add my scrape steps that we have to finish out the, I guess, most of the loop automation here. So I'll click plus, and then I'm going to scroll down to scrape, and then I'll just dismiss this really quick.

Okay. Sorry. That took its time loading that page. But I added that scrape step or sorry, started the recording of the scrape step. And now I'm going to add some things that I want to scrape. So the price, the rooms, bathrooms, parking, and then the size. And then I'll confirm this. And this is going to add all of those scrape steps inside of that loop.

Then I'll click I'm done. Since that's all for my use case on this automation, if we needed to click and type other things, we can just keep adding those steps. But this is all we have. So we go to a website, we scrape all of the elements on the page that we want to loop over. We add that loop step and we tell it we want to loop over step two.

Then inside of here, we're going to click on the first result, and then we're going to scrape all of the other details on the page that I wanted to. Task Magic will figure out how to handle whether or not, uh, this is a loop. Click is related to what you're scraping over or what you scraped. Um, you do not need to worry about any additional settings in any of these other steps.

So what this will do is it goes to this page, scrapes them all, then loops over all 15 of them. First one, it's going to click the first result. Scrape a bunch of stuff. Then we have that go back step that I talked about. We need to add here. So we'll click plus and then go back. We don't have those options available when we're recording.

So I'm adding that after the fact. So we clicked that thing, scrape a bunch. Then we go back by, which is basically the same as. clicking this back button. And then after we do that, the last step in the loop, it's going to restart with the next item in this list. It'll repeat that click, which is clicking that second item in the list that we scrape now, repeating all of these scrape steps before running, go back again.

So that's how you loop over things on the page. If you're having trouble with scraping links or anything like that, this is a really common use case, uh, or way to get around those types of problems. I'll go ahead and just click play steps here so that we can see what this looks like and a little bit of how this works when it's in action.

So what we're doing here is again, scraping all of these names on the page. I'm just going to scroll down really quick to show you guys this. We'll see all of these get highlighted. all of the names of that, the items in that list.

And then we're going to click on the first one.

After clicking, we will scrape all of those details at the top there.

And then we're going to run that go back step, which might happen a little quick after we do the scrape.

So there's all of our scrape steps. Then we went back and now we are going to click on the second item in the list. You'll see that it's highlighted everything and then clicked on the second result before it moved on to starting its scrape again. Okay.

 
Did this answer your question?
😞
😐
🤩