This was ‘fun’ so I made automation of extracting JSON data from the website:rgb.to
EDIT: Made a change after Shanes input.
use framework "Foundation"
use scripting additions
set theHexColor to "F0F8FF"
set targetURL to "https://rgb.to/save/json/color/"
log (my JSONContentsOfURLToRecord:(targetURL & theHexColor as string) colorModel:"rgb")
log (my JSONContentsOfURLToRecord:(targetURL & theHexColor as string) colorModel:"hsl")
log (my JSONContentsOfURLToRecord:(targetURL & theHexColor as string) colorModel:"hsb")
log (my JSONContentsOfURLToRecord:(targetURL & theHexColor as string) colorModel:"cmyk")
log (my JSONContentsOfURLToRecord:(targetURL & theHexColor as string) colorModel:"hex")
log (my JSONContentsOfURLToRecord:(targetURL & theHexColor as string) colorModel:"websafe")
on JSONContentsOfURLToRecord:_theURL colorModel:_colorModel
set theURL to current application's |NSURL|'s URLWithString:_theURL
set JSONData to current application's NSData's dataWithContentsOfURL:theURL
set {theResult, theError} to (current application's NSJSONSerialization's JSONObjectWithData:JSONData options:0 |error|:(reference))
set theResult to theResult as record
-- color model.
if (_colorModel is "rgb") then
return {r, g, b} of rgb of theResult
end if
if (_colorModel is "hsl") then
return {h, s, l} of hsl of theResult
end if
if (_colorModel is "hsb") then
return {h, s, b} of hsb of theResult
end if
if (_colorModel is "cmyk") then
return {c, m, y, k} of cmyk of theResult
end if
if (_colorModel is "hex") then
return hex of theResult
end if
if (_colorModel is "websafe") then
return websafe of theResult
end if
end JSONContentsOfURLToRecord:colorModel: