Module: Shrikanth

Defined in:
lib/shrikanth.rb,
lib/shrikanth/version.rb

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.parse(url) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/shrikanth.rb', line 6

def self.parse(url)
  html = RestClient.get(url).body
  parsed = Nokogiri::HTML.parse(html)
  image_tag = parsed.css("img")
  image_tag.each do |img|
    url = "http:#{img['src']}"
    name = url.split("/").last
    begin
      file = RestClient.get(url).body
      File.write(name,file)
   rescue
     puts "Invalid URL"
    end
  end
end