web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to get all URLs on...
Power Automate
Answered

How to get all URLs on a web page?

(0) ShareShare
ReportReport
Posted on by 6

Hi all - I would like to get all the URLs available on a web page similar to the Chrome console function that prints all the URLs in the console. 

 

 

var urls = document.getElementsByTagName('a');

for (url in urls) {
 console.log ( urls[url].href );}

 

 

Is the 'Run JavaScript Function on Web Page' the right function to use? If yes, how can I modify the code above to render the URLs? I have tried the following, but it only returns [object Object] as the result. 

 

 

var urls = document.getElementsByTagName('a');
var urlList = [];
for (var i = 0; i < urls.length; i++) {
 urlList.push(urls[i].href);}
return urlList;
}

 

 

Any pointers would be very much appreciated! ThanksCapture.PNG

I have the same question (0)
  • Verified answer
    VJR Profile Picture
    7,635 on at

     

    Add this in the javascript on webpage action.

     

    function ExecuteScript() 
    
    { 
    
    var links = document.getElementsByTagName('a');
    var list = "";
    for(var i = 0; i< links.length; i++)
    {
     list = list + links[i].href + "\n";
    }
    
    return(list);
    }

     

    Output in a Text variable:

    VJR_0-1674103009222.png

     

    Split it by newline using Split Text if you want the result in a List variable so that you can iterate through it.

     

    VJR_2-1674103427323.png

     

     

     

    List variable:

    VJR_1-1674103356962.png

     

  • fskdnl Profile Picture
    6 on at

    Thanks so much for the solution! Much appreciated.

     

    As a follow-up question, instead of getting all URLs on a web page, I would like to get all the URLs on a website when given a domain name. Can this be achieved via Power Automate Desktop as well? Thanks!

  • VJR Profile Picture
    7,635 on at

    This will definitely need you to know all links on that website.

    Some sites do have a sitemap, so you can try accessing that.

     

    Another thing you can look at is:

    - Launch <browser>

    - Get details of web page (this will give a variable)

    - Use that variable in "Recognise entities in Text" (select URL in dropdown)

     

    Then again go into each of the links generated using above steps and then again more links from those links.

    But of course this is going to extract every single thing that looks like an URL eg; image links, etc.

     

    You can do some research and see where/how it goes.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard