Created
February 21, 2011 01:59
-
-
Save deathbob/836569 to your computer and use it in GitHub Desktop.
Little script to help me catch up on my mashups!
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
| #!ruby | |
| require 'rubygems' | |
| require 'hpricot' | |
| require 'open-uri' | |
| require 'fileutils' | |
| prefix = Time.new.strftime("%F") | |
| FileUtils.mkdir(prefix) unless File.exists?(prefix) | |
| pages = (2..14).to_a | |
| pages.each do |page| | |
| doc = open("http://mashuptown.com/page/#{page}/") | |
| as = Hpricot(doc)/'a' | |
| mp3s = as.map{|x| x.attributes['href'] if x.attributes['href'].match(/\.mp3/)}.compact.uniq | |
| mp3s.each{|x| | |
| file = File.join(prefix, x.split('/').last) | |
| unless File.exists?(file) | |
| writeOut = open(file, "wb") | |
| writeOut.write(open(x).read) | |
| writeOut.close | |
| puts "downloaded #{x}" | |
| end | |
| } | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment