Last active
November 30, 2016 10:27
-
-
Save cptangry/66dddbe13f67b0251611375ea007537d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# coding: utf-8 | |
require 'nokogiri' | |
require 'mechanize' | |
xmlfile, xmlpath = ARGV | |
def download_image(url, index, link_sum, path) | |
agent = Mechanize.new | |
puts "İndiriliyor: #{url}" | |
agent.get(url).save "./#{path}/#{url.split('/').last}.jpg" | |
puts "#{index + 1}/#{link_sum} dosya indirildi! | |
#{index + 1} adet dosyanın indirilmesi tamamlandı!" | |
end | |
xmldata = Nokogiri::XML(File.open("#{xmlfile}")) | |
indirme_linkleri = xmldata.xpath("//#{xmlpath}").map {|link| link.text}.to_a | |
indirme_linkleri.each_with_index do |link, index| | |
download_image(link, index, indirme_linkleri.size, xmlpath) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment