Sha256: c5866b20d172640b1abd7e3d839443c25088a6bd860c8e4ee8c08125493026c2
Contents?: true
Size: 424 Bytes
Versions: 1
Compression:
Stored size: 424 Bytes
Contents
require 'open-uri' require 'nokogiri' module ImageScraper def self.image_urls(url, convert_to_absolute_url=true) uri = URI.parse(url) domain = "#{uri.scheme}://#{uri.host}" doc = Nokogiri::HTML(open url) urls = [] doc.xpath("//img").each do |img| image = img["src"] image = domain + image if convert_to_absolute_url and !image.include?("://") urls << image end urls end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
image_scraper-0.0.1 | lib/image_scraper.rb |