Class: JekyllImageData::Crawler

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-image-data/crawler.rb

Instance Method Summary collapse

Instance Method Details

#crawl(content) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/jekyll-image-data/crawler.rb', line 5

def crawl(content)
  images = []
  html = Nokogiri::HTML(content)
  html.xpath("//img").each do |item|
    images << {
      "url" => item.xpath("@src").first.content,
      "alt" => item.xpath("@alt").first.content
    }
  end
  images
end