Skip to content

Instantly share code, notes, and snippets.

@jpleau
Last active August 29, 2015 14:04
Show Gist options
  • Save jpleau/2e6322dfefd64794127f to your computer and use it in GitHub Desktop.
Save jpleau/2e6322dfefd64794127f to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import re
import requests
from bs4 import BeautifulSoup
from distutils.version import LooseVersion
our_version = LooseVersion("1.04")
url = "http://ftp.gnu.org/gnu/bc/"
html_content = requests.get(url).text
soup = BeautifulSoup(html_content)
print("Our version: {}".format(our_version))
new_version = None
for tag in soup.find_all("a"):
match = re.match("bc-(?P<version>([A-Za-z0-9\.]+)).tar.(.*)", tag['href'])
if match:
other_version = LooseVersion(match.group("version"))
if other_version > our_version and (not new_version or other_version > new_version):
new_version = other_version
if not new_version:
print("Up to date!")
else:
print("New upstream release: {0}".format(other_version))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment