Skip to content

Instantly share code, notes, and snippets.

@KisaragiEffective
Created July 15, 2020 08:18
Show Gist options
  • Save KisaragiEffective/6ed1306bcd7e0a67c8a1d78b7d871ff2 to your computer and use it in GitHub Desktop.
Save KisaragiEffective/6ed1306bcd7e0a67c8a1d78b7d871ff2 to your computer and use it in GitHub Desktop.
parse web color dict.
require "nokogiri"
require "open-uri"
html = open("https://www.colordic.org")
doc = Nokogiri::HTML.parse(html, nil, "UTF-8")
# [0]: html color name, [1]: actual color code headed '#'
doc.css('table')[0].css("td").map {|x| x.css("a")[0].inner_html.split("<br>") }
# TODO: other format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment