Skip to content

Instantly share code, notes, and snippets.

@forresty
Created October 26, 2011 03:19
Show Gist options
  • Save forresty/1315321 to your computer and use it in GitHub Desktop.
Save forresty/1315321 to your computer and use it in GitHub Desktop.
THIS IS EVIL...
#!/usr/bin/env ruby
require "uri"
require "open-uri"
require "nokogiri"
def extract_flv(page_url)
url = nil
open(page_url) { |page| page.read }.each_line do |line|
url = URI.unescape($1) if line =~ /to\.addVariable\(\"video_url\",\"(.*)\"\)/
end
[ url, url.match(/(\d+\.flv)/)[0] ]
end
def extract_links(n)
doc = Nokogiri::HTML(open("http://www.pornhub.com/video?o=tr&t=a&page=#{n}") { |page| page.read })
doc.css("li.videoblock a.img").map { |a| a['href'] }
end
trap("INT") { exit }
1.upto(10) do |i|
extract_links(i).each do |link|
url, filename = extract_flv(link)
cmd = "axel -a -n 10 -o '#{filename}' '#{url}'"
puts "executing `#{cmd}`"
system(cmd)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment