Reputation: 11
I am a teacher trying to build a flow on Microsoft Power Automate to automate a task involving checking grades. The task (the human version) is simple: log into the grade website, navigate to my list of students, click on each student, and record their current grades in an excel sheet (the grades are in an HTML table).
So far, I have been able to automate for only one student at a time. I can click their name, have power automate wait for the HTML table to appear, extract the data, format the data table to only keep the columns I want, and insert the data into my pre-made spreadsheet.
I am having trouble figuring out how to iterate through this list/table of students. Power Automate recognizes the student names as hyperlinks, not links on a webpage or UI elements. But the URL of the webpage does not change upon clicking the hyperlink. The attribute when I inspect the element is this:
<a class="pointer" type="button" onclick="ShowDetails(this)>LastName,FirstName
(It does not actually say "LastName,FirstName" - it says the actual student name and I cannot include their names in this post for data privacy reasons).
I have tried this method of clicking links in a table, but when he clicks extract, there is an href= option, but I do not have that on my table. I have tried using the recorder, but it is tedious because I have 40 students to check for and the whole point of this was to not click everything individually. I have tried the "move mouse to text on screen (OCR)" method, but the student name hyperlinks are not recognized as text. I've also tried "move mouse to image," but I do not want to screenshot every student individually.
I have all the student names stored in a list in Power Automate and my goal was for the flow to do the HTML table extraction for each name in the list: click the given name, wait for the table to appear, extract the data.
Is there a way to iterate through this list somehow? Like "for each" row in the list, click on its matching link on the page and extract the table?
Upvotes: 1
Views: 198
Reputation: 87
It's not possible for me to answer your question without access to the page you're trying to scrape. However, I can give some advice. Since I don't know your page, please consider my response as if "I'm guessing that ..." were before every sentence.
Don't do this
Scraping web pages for data is highly inaccurate. It's too easy to accidently miss some data, to include wrong data, to accidentally download gigabytes of spam, all without warning or knowing.
Instead, contact the owner of the page and find if there is some API you can query, or raw data to download. This is much safer and more accurate than web scraping.
But if you have to
The title of the video you linked to is "Click all Links in Table or List ..." The technique he uses only works on an HTML table or list. The first thing he does is extract the entire list to %OutputData%
.
Then he creates a UI element to one of the elements of the list. He wants to extract the href attribute but you don't want that. Capture the a
element from your page, not an attribute, not the text; you want to click it, not extract data.
Then create a loop from 0 to %OutputData.RowsCount - 1%
. Edit the UI element you just created to use the loop variable you just created to specify a selector dependent on the list row, not on the element you clicked. Use the text editor, not the GUI. For example, if the UI Element you clicked resulted in a selector of
table[Id="students"] > tbody > tr > td > div > a[Text="LastName, FirstName"]
You want to change it to something like:
table[Id="students"] > tbody > tr:eq(%LoopIndex%) > td > div > a
Note this is totally page dependent; every web page can be totally different. You may want to view the page source to determine the classes, attributes, and indexes that will specify the element for each student.
Once you've created your dynamic UI element, use it as the target of a Click Link on Web Page action inside the loop.
This is a highly-simplified version of what you need to do; if your page has any other dynamic content you will have to extract it and use that for additional changes in creating your selector. This is not a job for a beginner.
Upvotes: 0