I thought it would be fun to create python program that scrapes colors from websites. So I did.

I am not very used to python, so python was an obvious choice.

So what my litte program does is:

  1. requesting a html page from the given url
  2. looking for link tags to find css - using regular expressions
  3. requesting that css
  4. parsing css for color values - again some regular expressions magic :sparkles:
  5. converting those color values to rgb (used colorsys for that)

A small snippet, how this program may be used:

url = 'https://timobechtel.com'
handler = RequestHandler(url)
html = handler.get()

html_parser = HTMLStyleParser(html)
css = html_parser.load_css(handler)

color_parser = CSSColorsParser(ColorGenerator())
colors = color_parser.parse_colors(css)

for color in colors:



I might upload this to Github later, if there’s interest.