Get Direct Download Link from a web page using Invoke-WebRequest cmdlet

Hello community,

I am trying to get a “direct download” link from a web page using Invoke-WebRequest cmdlet.

The problem is that the website uses a session management cookie to produce the “direct download” link and I cannot reach this link.

The web page has kind of “download now” button that redirects you to another (“thank you page”) page and then the download starts automatically.

How can I get this direct download link?? Can anyone help?

PS: I searched for the download link withing the “Links” property of the web request but it is not there. I guess that something can be done using the cookie info that I get using the session variable but I cannot reach the direct download link.

Thank you all in advance

without knowing what site you are trying to retrieve, I cannot say for sure, but it is very likely that the site uses javascript to populate the direct download target, which is done client side. As such, this processing will not have already been done during the invoke-webrequest process and Invoke-WebRequest cannot render javascript.

Thank you for the reply Curtis Smith.
You are right, the site uses javascript to populate the direct download link.

Look I found a way to isolate the phpsession cookie that produces the direct download link in order to use it and get the direct download link but I m stuck on that.

I found on the web some kind of linux bash commands to retrieve the direct download link.
Once you find the phpsession cookie then you type the following to get the direct download link saved in a txt file:

printf “GET /files/service/thankyou?id=5125790 HTTP/1.0\r\nHost: www.webpage.com\r\nCookie: PHPSESSID=1mcbhc3hv5h4iid1rddfr7vqk6\r\n\r\n” | netcat webpage.com 80 > 2.txt

The concept is that I cannot make a request the web page to reach the direct download link.

Thank you in advance…