Football Kit Colours
Scraping Wikipedia infoboxes with Python Beautiful Soup and Pillow to extract primary kit colours across the top 10 tiers of the English football league system.
- Published
- Updated
- Reading
- 1 min
- Filed under
- #python #football #data #wikipedia
Update (30/08/2019): Colours updated for the 2019/20 season.
I needed a set of colours to use for a football score display I was building; unfortunately I couldn’t find any available source for this, so I set about creating my own.
Fortunately Wikipedia was able to come to the rescue. Wikipedia is great for finding lists of items and it does have a list of all football clubs within the first 10 levels of the English Football League system on Wikipedia.
From this list it also links to the Wikipedia page of the club where one exists (a few of the clubs in the lower tiers do not yet have Wikipedia pages). The infobox on these football club pages also shows the club’s kits — this may be empty for some of the smaller teams, just show the Home kit, or show the Home, Away, and Third kits.
Through Python’s Beautiful Soup library I was able to go through the complete list of football teams and find these kit images for each team. These images were then analysed by Python’s Pillow library to break them into blocks of similar colours. Any colour meeting set thresholds was then stored as a primary kit colour for that club.
Currently these colours are for the 2018/19 season and will be updated for 2019/20 near the beginning of the season once new kits have been revealed and their Wikipedia pages updated.
These club colours have been made available at sandbox.andylawton.com/football-colours/.
Should anyone have use of this data in a different format I will be happy to provide it — get in touch using the contact form on this website.
