Skip to content

Instantly share code, notes, and snippets.

@Enchufa2
Created November 30, 2013 10:53
Show Gist options
  • Save Enchufa2/7717627 to your computer and use it in GitHub Desktop.
Save Enchufa2/7717627 to your computer and use it in GitHub Desktop.
Dropbox recursive downloader
#!/usr/bin/env python
# coding=UTF8
# Author: Iñaki Ucar <i.ucar@enchufa2.es>
# Description: Dropbox recursive downloader
import os, sys
from urllib2 import urlopen, unquote
from bs4 import BeautifulSoup
from subprocess import call
if len(sys.argv) != 3:
print 'Use: ./dropbox-downloader.py <path> <url>'
exit()
path = sys.argv[1]
url = sys.argv[2]
def downloader(url):
soup = BeautifulSoup(urlopen(url))
for a in soup.find_all('a', 'filename-link'):
href = a.attrs['href']
name = unquote(href.split('/')[-1])
if name.find('.') == -1:
os.mkdir(name)
os.chdir(name)
downloader(href)
else:
call(['wget', href])
os.chdir('..')
os.chdir(path)
downloader(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment