DetectVersion
tim-lebedkov edited this page Nov 26, 2022
·
3 revisions
Many popular programs have a page at wikipedia.org, but do not provide an easily accessible version number on their own web site. Here is an example of how to detect the newest version number for Skype:
- Find the Skype page on Wikipedia: https://en.wikipedia.org/wiki/Skype
- Click on "View source": https://en.wikipedia.org/w/index.php?title=Skype&action=edit
- Click on "Template:Latest stable software release/Skype": https://en.wikipedia.org/wiki/Template:Latest_stable_software_release/Skype
- Use the MediaWiki/Wikipedia API to grab the page content as XML: https://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=Template%3ALatest_stable_software_release%2FSkype&rvslots=%2A&rvprop=content&formatversion=2&format=xml
- Use the following regular expression to find the version number: version2\s+=\s+([\d.]+)
Github offers an API that can be used to detect the newest version of a package. Here is an example of how to detect the newest version number and package URL for Notepad++:
- call the API https://api.github.com/repos/notepad-plus-plus/notepad-plus-plus/releases/latest
- search in the JSON using this regular expression: notepad-plus-plus/notepad-plus-plus/releases/download/v([\d.]+)/npp.([\d.]+).Installer.x64.exe
- use the following expression to construct the URL: https://github.com/${match}