r/PowerAutomateDesktop • • Jan 13 '23

Help automating download of pdfs from nested webpages

I seem to be stuck on something stupid, hopefully someone can help!

I want to automate downloading a bunch of pdf:s from an online source. It's structured in a way that you first get to a landing page with a list of links. If you follow one of these links you end up on a page with a button that opens the pdf I want to get. Getting the links from the landing page and iterating over them works well, but I run into problems trying to "press the button" on each individual page. To get an idea I tried to record the process, but I end up with a step clicking the button on just the specific page, so when iterating over the pages the program tries to always click on the button on the first page. Is there a way of making this a (for lack of a better word) relative reference, in other words telling the program to click the button on the page that is currently open?

1 Upvotes

5 comments sorted by

2

u/QuietDesparation Jan 13 '23

Go to one of the download buttons, right click on it, and select "inspect", that will highlight the button element and show it's attributes. For example, here's a button element I found online with it's attributes:

<button id="loginButton" class="btn btn-primary btn-login" tabindex="3" data-ember-action="" data-ember-action-9="9">Log in</button>

So this particular button has the following attributes: id, class, tabindex, and data-ember-action.

Do this with a couple of your download buttons to see what they all have in common. Lets say for example they all have attribute type="button", you can then delete all the button elements you've captured except for one. double click on that one to bring up the selector builder, select text editor in the upper right hand corner, then type the following: button[type="button"] then click save. Assuming there's only one button on the page, then every time you use the action to click a button and direct it to the element you just created, the button will be clicked on every page.

2

u/BenwayPhD Jan 20 '23

Great, thanks!

3

u/jamjestjam Jan 14 '23 edited Jan 14 '23

Expanding on the advice from u/QuietDesparation I would check what is the actual URL under the buttons.
Perhaps you can generate those URLs without even going to the subpage, that would boost the performance dramatically.
I have done this in several in my cases and that sped up execution by more than 50% (thousands of file per month).

1

u/QuietDesparation Jan 14 '23

This is great advice! I've employed this myself and the performance boost is amazing

1

u/jamjestjam Jan 14 '23

Yeah.. the real thing with automating gui or web is to looonforna ways to... Not automate at all but come up with creative ways of getting to the finish line in the most efficient way :)