Tobias Nilsson
Tobias Nilsson

Reputation: 41

Invoke-WebRequest produces different result from browser

I am working on a script to update Java to the latest version. To be able to find the latest version I use the following command to find all the downloadable files:

(Invoke-WebRequest –Uri 'http://www.java.com/en/download/manual.jsp').links

And it gives me a link that is http://javadl.sun.com/webapps/download/AutoDL?BundleId=95123. That links to the 32 bit version, but I can't find the link to 64 bit version. But if I open the page in a web browser I get a different result, because now I can find the link to the 64 bit version (http://javadl.sun.com/webapps/download/AutoDL?BundleId=95125).

Why is the script giving me a different result than the web browser?

Upvotes: 1

Views: 2105

Answers (1)

hysh_00
hysh_00

Reputation: 839

I think the server-side is looking into the UserAgent info. Please try this way:

(Invoke-WebRequest -Uri 'http://www.java.com/en/download/manual.jsp' -UserAgent "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36").links

Upvotes: 1

Related Questions