require 'nokogiri' #install gem nokigiri
require 'open-uri'
require 'openssl'
def get_page(url)
return Nokogiri::HTML(open(url, {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE}))
end
def read_file(the_html_file)
return Nokogiri::HTML(open(the_html_file))
end
html_file = 'C:\Users\OSMCAN\Desktop\baliwtm.html'
page = read_file(html_file)
#puts page
sources = page.css('source').map { |source| source['src'] }
#puts sources
sources.each do |url|
if url.include? "?"
url = url.split('?').first
end
puts url
the_filename = File.basename(url)
puts "the_filename: #{the_filename}"
the_url = "#{File.dirname(url)}/#{the_filename}"
puts "the_url: #{the_url}"
open(the_filename, 'wb') do |file|
file << open(the_url, {ssl_verify_mode: 0}).read #require 'openssl'
end
#exit
end
Comments
Post a Comment