Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

fp more pronporn scrapper

View 1.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
#!/usr/bin/env ruby
 
require 'nokogiri'
require 'open-uri'
require 'net/http'
require 'uri'
require 'fileutils'
require 'colorize'
 
def file_name path
path.split( File::SEPARATOR ).last
end
 
# Make results dir
dir = File.join Dir.pwd, "results"
FileUtils.mkdir_p dir
 
# Request URL
puts "Page URL:"
page = Nokogiri::HTML open gets.chomp
 
links = page.css( "img" ).map { |img| img['src'] }
 
hosts = links.map { |x| URI x }.group_by &:hostname
 
hosts.each do |hostname, uris|
http = Net::HTTP.start hostname
 
uris.each do |uri|
resp = http.get uri.path
puts "Downloading '#{file_name uri.path}'"
name = file_name uri.path
file_path = File.join dir, name
open file_path, "wb" do |file|
file.write resp.body
end
end
end
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.