How to find the URL to download a package by command curl

Asifahmed
New Contributor III

Hello All,

How can I find the URL to download a package from URL using by curl command, I opened the URL to download Google Chrome installer for mac and then stop it download through GUI and copied the URL and opened the terminal and putted the command curl -o URL of GC source, it is giving me error saying zsh: parse error near &

Any idea how to find the correct URL for curl?

8 REPLIES 8

Tribruin
Valued Contributor II

If you just copied and pasted the link to the Chrome download page, you probably are not getting the correct URL since the page has more than just the download, it is a full webpage. You probably could inspect the source code of the webpage to find the actual link that it being called.

But, you are doing a lot of work that others have already done for you. Take a look at Installomator. (Installomator/Installomator: Installation script to deploy standard software on Macs (github.com))

It is a much better solution for installing applications than trying to build a list of URLs (which could change) by yourself. 

Asifahmed
New Contributor III

Understood but for learning purpose how to find the actual link to download any package?

I just download the software in Chrome and when going to Settings->Downloads it shows the exact URL that is being downloaded.  You would just use that in your curl command.

williamaddis_0-1688647874948.png

 

I cant see on my mac after download and installation Google Chrome browser, I also used Google Chrome to download it.

You can do the same thing in Safari.  Just right-click and copy address.

williamaddis_0-1688650292422.png

 

Oh great, now I am able to see also, thanks for help. Will check for Firefox and others too. thanks again!

Tribruin
Valued Contributor II

Even if you don't use the product, Installomator has a lot of the URLs or how to find them programmatical. Look at the individual labels for each product that you are interested. For example, if you look up Google Chrome, you can find this line:

downloadURL="https://dl.google.com/chrome/mac/stable/accept_tos%3Dhttps%253A%252F%252Fwww.google.com%252Fintl%252..."

Other packages will be similar. 

Bol
Valued Contributor

@Asifahmed 

You would use the --location switch which tells curl to continue if the url is a redirect. To output the url you would also use --write-out for effective url. If you use the MS Word installer for example, top url is;

https://go.microsoft.com/fwlink/?linkid=525134 

/usr/bin/curl --silent --show-error --head --location --write-out '%{url_effective}\n' "https://go.microsoft.com/fwlink/?linkid=525134" -o /dev/null
https://officecdnmac.microsoft.com/pr/C1297A47-86C4-4C1F-97FA-950631F94777/MacAutoupdate/Microsoft_Word_16.74.23061100_Installer.pkg