Created
December 26, 2011 19:20
-
-
Save navinpai/1521963 to your computer and use it in GitHub Desktop.
Sinatra :: Get Dropbox public folder contents as JSON file
This file contains 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
#Basically the heart of the Publicbox (https://github.com/hmans/publicbox) code | |
# See whole file at: https://github.com/hmans/publicbox/blob/master/config.ru | |
get '/*' do |path| | |
doc = Nokogiri::HTML(open("https://www.dropbox.com/#{path}").read) | |
files = [] | |
doc.css('#list-view div.filerow').each do |row| | |
files << { | |
filename: row.css('div.filename a').first.content.strip, | |
size: row.css('div.filesize span.hidden').first.content.to_i, | |
modified: row.css('div.modified span.hidden').first.content.to_i, | |
url: row.css('div.filename a').first['href'] | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment