I have a Bash script which downloads a source file and installs the package. I would like to get the latest version of a package from the website instead of manually updating the script. Beautifulsoup would seem ideal for this. As an example, take the website for Gnome packages -
https://download.gnome.org/sources/
Say I want the latest version of gnome-common. So far I have come up with this:
#!/usr/bin/env python3
from bs4 import BeautifulSoup
import requests
import re
URL="https://download.gnome.org/sources/gnome-common"
page = requests.get(URL)
soup = BeautifulSoup(page.content, "html.parser")
links=soup.find_all("a", href=re.compile("[0-9]"))
print(links)
This gets all the package versions from the site but a whole lot more, so I'm not sure how to proceed. What I want is the list of just the version numbers, then I want to determine the latest version (highest number), then add this to the URL , go to that site and get the latest source tarfile.
So for gnome-common, the latest version is 3.18 and from https://download.gnome.org/sources/gnome-common/3.18/ the latest package is 3.18.0, which is what I will download in the Bash script.