Jelle van der Waa bio photo

Jelle van der Waa

I'm a software developer at Kopano and an Arch Linux Developer...

Email Twitter Google+ LinkedIn Github Steam

I’ve talked about an urlwatch systemd timer setup, but monitoring github pages is troublesome since the HTML data changes per visit. Luckily urlwatch has support for hooks, which triggers after the data has been retrieved and before the data is compared with the previous retrieved data. Hooks can be created by creating a file in ~/.urlwatch/libs/hooks.py with the following content.

from BeautifulSoup import BeautifulSoup

def filter(url, data):
	if 'github' in url:
		soup = BeautifulSoup(data)

		if soup.find('span', {'class': 'tag-name'}):
			return str(soup.find('span', {'class': 'tag-name'}))
		elif soup.find('h1', {'class': 'release-title'}):
			return str(soup.find('h1', {'class': 'release-title'}))
		else:
			return data
	else:
		return data

This filter is targeted at Github release and tags pages like for example: https://github.com/scipy/scipy/releases.