Posted on 07-06-2023 02:26 AM
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?
Posted on 07-06-2023 04:42 AM
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.
Posted on 07-06-2023 05:35 AM
Understood but for learning purpose how to find the actual link to download any package?
Posted on 07-06-2023 05:51 AM
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.
Posted on 07-06-2023 06:23 AM
I cant see on my mac after download and installation Google Chrome browser, I also used Google Chrome to download it.
Posted on 07-06-2023 06:31 AM
You can do the same thing in Safari. Just right-click and copy address.
Posted on 07-06-2023 06:39 AM
Oh great, now I am able to see also, thanks for help. Will check for Firefox and others too. thanks again!
Posted on 07-06-2023 06:27 AM
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.
Posted on 07-07-2023 09:13 AM
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