Skip to content

Instantly share code, notes, and snippets.

View jeroeningen's full-sized avatar

Jeroen van Ingen jeroeningen

View GitHub Profile
#get the attribute from a given url (image) by using OCR
def ocr_attribute url
dir = "/tmp/scrapers"
file = rand(36**10).to_s(36)
path = "#{dir}/#{file}"
pnm_path = "#{dir}/#{file}.pnm"
open(url) do |f|
Dir.mkdir(dir) if !File.exists? dir
image = Image.from_blob(f.read)[0]
image.write(path)