lib/nokaya/getter.rb in nokaya-0.0.1 vs lib/nokaya/getter.rb in nokaya-0.0.2
- old
+ new
@@ -15,28 +15,20 @@
end
def url
@args.url
end
def get_image img_link
- open(img_link).read
+ begin
+ open(img_link).read
+ rescue
+ abort Status.no_can_do
+ end
end
def get_link page
page.xpath("//meta[@property='og:image']/@content").first
end
- def photo_name
- unless @args.options[:name]
- Dir.home + "/Downloads/#{@args.type.to_s}-#{Time.now.to_i}.jpg"
- else
- Dir.home + "/Downloads/#{@args.type.to_s}-#{@args.options[:name]}.jpg"
- end
- end
def parse_page
Nokogiri::HTML get_page_content
- end
- def save_image path, img_link
- f = File.new(path, "wb")
- f.puts(get_image img_link)
- f.close
end
private
def get_page_content
open @args.url
end