Created
February 12, 2011 17:28
-
-
Save fredoliveira/823891 to your computer and use it in GitHub Desktop.
The script I use to backup my ffffound items. Far from perfect, and the system call is quite a hack, but I was in a hurry and this does it for me.
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
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
pages = 78 | |
username = "fred" | |
def grab_url(offset) | |
Nokogiri::HTML(open("http://ffffound.com/home/#{username}/found/?offset=#{offset}")) | |
end | |
def parse_document(doc) | |
doc.css('.description').each do |l| | |
url = "http://" + l.children[0] | |
url = url.split("?")[0] | |
`cd img; wget #{url}` | |
end | |
end | |
for i in 0..pages | |
puts "Downloading page ##{i} of ##{pages}" | |
parse_document(grab_url(i * 25)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment