lib/image_scraper/client.rb in image_scraper-0.1.5 vs lib/image_scraper/client.rb in image_scraper-0.1.6
- old
+ new
@@ -20,10 +20,11 @@
def page_images
urls = []
return urls if doc.blank?
doc.xpath("//img").each do |img|
+ next if img["src"].blank?
image = URI.escape(img["src"])
image = ImageScraper::Util.absolute_url(url,image) if convert_to_absolute_url
urls << image
end
urls
@@ -39,20 +40,20 @@
image_url = URI.escape image_url[0]
if image_url.include?("data:image") and @include_css_data_images
image_url
else
image_url = ImageScraper::Util.strip_quotes(image_url)
- @convert_to_absolute_url ? ImageScraper::Util.absolute_url(url,image_url) : image_url
+ @convert_to_absolute_url ? ImageScraper::Util.absolute_url(stylesheet, image_url) : image_url
end
end
end
images
end
def stylesheets
return [] if doc.blank?
doc.xpath('//link[@rel="stylesheet"]').collect do |stylesheet|
- URI.escape ImageScraper::Util.absolute_url(url,stylesheet['href'])
+ ImageScraper::Util.absolute_url url, URI.escape(stylesheet['href'])
end
end
end
end