简体   繁体   中英

Use Regex to detect the latest direct download link URL and thus quickly DL the latest software using AHK or other script lang

I am attempting to use AutoHotkey to launch google chrome to a specific URL that will download the latest version of CCleaner.exe. Everytime a new version is released the version numbers change the URL. How can I open chrome and detect the current correct URL that will allow me to download the file. Currently I get an error because my URL is out of date and no loger representative of the latest release.

for my ahk script I have used this with success to open chrome to the url of my choosing. I just am not sure how to get it to auto detect the new URL of the next software version.

~d & ~c::
    If WinExist("ahk_exe chrome.exe")
        {
        Run, "chrome.exe" --new-tab "https://download.ccleaner.com/ccsetup559.exe", C:\Program Files (x86)\Google\Chrome\Application\, Max, chromePID
        WinWait, ahk_pid %chromePID%,, 1
        WinActivate, ahk_pid %chromePID%,, 1
        WinWaitActive, ahk_pid %chromePID%,, 1
        Return
              }
    Else {
        Run, chrome.exe --new-tab "https://download.ccleaner.com/ccsetup559.exe", C:\Program Files (x86)\Google\Chrome\Application\, Max, chromePID
        WinWait, ahk_pid %chromePID%,, 1
        WinWaitActive, "ahk_exe chrome.exe",, 1
        Return
              }

My current script will open the URL ( https://download.ccleaner.com/ccsetup559.exe ) that I listed in my code. However, it won't change to the latest URL that has the new version number for the latest software release and thus gives an error. The new URL could look like the following as an example ( https://download.ccleaner.com/ccsetup601.exe ) How can I open chrome to the general url and auto detect the correct download link that has the latest version. Thank you!

Maybe you should go on the following link: https://www.ccleaner.com/ccleaner/download/standard and look the download URL which has this pattern:

https:\/\/download.ccleaner.com\/ccsetup(\d*).exe

Following this documentation: https://www.autohotkey.com/docs/commands/RegExMatch.htm

FoundPos := RegExMatch(yourURL, "https:\/\/download.ccleaner.com\/ccsetup(\d*).exe", VersionValue)

And then use VersionValue .

The (\\d*) will catch the digits.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM