Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Power Automate Desktop
Answered

How to get all links on a webpage into a list variable?

Like (0) ShareShare
ReportReport
Posted on 9 Mar 2024 22:07:57 by 43

Hi all -

 

My apologies in advance if this is something with an obvious answer. I've consulted documentation and Copilot and Microsoft Learn and nothing I've tried so far has worked. I'm new to RPA and Power Automate, and my background is in data analytics and reporting, so I don't have a great deal of experience with front-end GUI components, and I think that lack of knowledge is hurting me here.

 

I'm working on a desktop flow to automate the process of copying data out of web-based lab information management system named LabVantage. As far as I've been able to determine, there is not customer connector for accessing the data in this system via the back end. In the flow, I have a variable named "BatchNumber" that holds a string value. The flow opens LabVantage with a "Open Microsoft Edge browser" action that navigates to the appropriate location. On the LabVantage page, there will be a table with a varying number of rows. The leftmost column of the table contains hyperlinks, one for every row, and the text labelling one of the hyperlinks will match the string value that's stored in BatchNumber. I'd like to make the flow click on the link with the matching label value, but I haven't been able to figure out how to get the list of hyperlinks into a list variable that I can iterate through to see if there's a match.
 

  • Deenuji_Loganathan_ Profile Picture
    6,105 Super User 2025 Season 1 on 11 Mar 2024 at 14:52:13
    Re: How to get all links on a webpage into a list variable?

    @Ipsifendus 

    1. How to change  them from the default values of "Column1" and "Column2" in the "Create new data table" action:

    Just click on the header column name and type something, you can able to change it

    Deenuji_0-1710168301641.png

    2. How to access the code:

    Pls follow the below steps

    Deenuji_1-1710168643685.png

    Deenuji_2-1710168713977.png


    Thanks,
    Deenuji Loganathan
    🤖 Automation Evangelist
    Deenuji - Follow me on LinkedIn

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🌟

  • Ipsifendus Profile Picture
    43 on 11 Mar 2024 at 14:41:53
    Re: How to get all links on a webpage into a list variable?

    Thanks, Deenuji, this was extremely helpful. If you don't mind a couple of follow up questions:
    * How did you assign the column names to the HyperlinkDataTable object? I can't change them from the default values of "Column1" and "Column2" in the "Create new data table" action.
    * Where can I access the code view of the flow that you provided an the end of your response?

     

    And thanks once again for your nicely detailed response!

     

  • Verified answer
    Deenuji_Loganathan_ Profile Picture
    6,105 Super User 2025 Season 1 on 11 Mar 2024 at 04:10:00
    Re: How to get all links on a webpage into a list variable?

    Hi @Ipsifendus,

    Please follow the below example related to your use case:

     

    1. Launch Google Chrome:

    Open Google Chrome browser and Go to the URL: https://en.number13.de/adding-clickable-links-to-a-html-table/.

    2. Extract HTML Table Data:

    Locate the HTML table within the webpage.

     Deenuji_0-1710129083560.png

     

    Extract data from the HTML table as mentioned in the above screenshot and these table text extracted as data table

     

    3. Retrieve Data into a List:

    Retrieve the data from the first column of the extracted table.

    Store the retrieved data into a list named ColumnAsList like below.

    Deenuji_1-1710129192526.png

     

     

    4. Create a New DataTable for Hyperlinks:

    Create a new DataTable with columns named 'Text' and 'Hyperlink'.

    Initialize an empty DataTable named HyperlinkDataTable.

    Deenuji_2-1710129445567.png

     

    5. Loop Through Each Item in the List:

    For each item in the ColumnAsList:

    • Trim any leading or trailing spaces from the text.
    • Identify the hyperlink associated with the text using "Get details of element on web page" like below
    • Deenuji_3-1710129583089.png

       

    • And in the UI element replace anchor text with variable(where it hold of current hyperlink text)

      Deenuji_4-1710129641017.png

       

    • Extract the href attribute value from the hyperlink
    • Append a new row to the HyperlinkDataTable containing the trimmed text and the extracted href attribute value.

    Now we have "HyperlinkDataTable". Its kind of temp datatable where it hold your table text and hyperlinks like below:

    Deenuji_5-1710129858441.png

    Then you can use another for each loop to iterate your temp datatable to find your text is matching or not.

    Deenuji_6-1710129987702.png

    Hope this helps!!

    Full flow details:

    Deenuji_7-1710130057102.png

     

    Code[you can copy and paste the below code in your PAD designer but recapture all the UI selector]:

     

    WebAutomation.LaunchChrome.LaunchChrome Url: $'''https://en.number13.de/adding-clickable-links-to-a-html-table/''' WindowState: WebAutomation.BrowserWindowState.Maximized ClearCache: False ClearCookies: False WaitForPageToLoadTimeout: 60 Timeout: 60 PiPUserDataFolderMode: WebAutomation.PiPUserDataFolderModeEnum.AutomaticProfile BrowserInstance=> Browser
    WebAutomation.ExtractData.ExtractHtmlTable BrowserInstance: Browser Control: $'''html > body > div:eq(0) > div > div:eq(0) > div:eq(1) > table''' ExtractionParameters: {[$'''Value #1''', $'''Value #2'''], [$'''''', $''''''] } PostProcessData: False TimeoutInSeconds: 60 ExtractedData=> DataFromWebPage
    Variables.RetrieveDataTableColumnIntoList DataTable: DataFromWebPage ColumnNameOrIndex: 0 ColumnAsList=> ColumnAsList
    Variables.CreateNewDatatable InputTable: { ^['Text', 'Hyperlink'], [$'''''', $''''''] } DataTable=> HyperlinkDataTable
    LOOP FOREACH CurrentItem IN ColumnAsList
     Text.Trim Text: CurrentItem TrimOption: Text.TrimOption.Both TrimmedText=> TrimmedText
     WebAutomation.GetDetailsOfElement BrowserInstance: Browser Control: appmask['Web Page \'h ... tml-table/\'']['Anchor \'Cities Skylines\''] AttributeName: $'''HRef''' AttributeValue=> AttributeValue
     Variables.AddRowToDataTable.AppendRowToDataTable DataTable: HyperlinkDataTable RowToAdd: [TrimmedText, AttributeValue]
    END
    LOOP FOREACH CurrentItem2 IN HyperlinkDataTable
     Text.ParseText.ParseForFirstOccurrence Text: CurrentItem2[0] TextToFind: $'''\"your text\"''' StartingPosition: 0 IgnoreCase: False OccurrencePosition=> Position
    END

     

     

     


    Thanks,
    Deenuji Loganathan
    🤖Automation Evangelist
    Deenuji - Follow me on LinkedIn

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🌟

  • UshaJyothiKasibhotla Profile Picture
    6 Super User 2025 Season 1 on 10 Mar 2024 at 16:30:59
    Re: How to get all links on a webpage into a list variable?

    Hi @Ipsifendus 

    Use extract data from we page action

    and there will be live web helper pop up and select extract drop down whatever you need like single value, table, list etc....please refer below image

    UshaJyothi20_0-1710088234553.png

     

    Hope this helps

    Usha.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,731 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,075 Most Valuable Professional

Leaderboard
Loading started