Skip to content

Instantly share code, notes, and snippets.

@rhiaro
Created March 23, 2016 10:57
Show Gist options
  • Save rhiaro/b9027def28ab437a6e9d to your computer and use it in GitHub Desktop.
Save rhiaro/b9027def28ab437a6e9d to your computer and use it in GitHub Desktop.
Download all files in a container from a Solid server to local disc
import sys
from rdflib import Graph, URIRef, Namespace
import urllib
LDP = Namespace("http://www.w3.org/ns/ldp#")
def main(localdir, remote):
g = Graph()
g.parse(remote)
for s, p, o in g.triples( (URIRef(remote), LDP.contains, None) ):
filename = o.split('/')[-1]
urllib.urlretrieve(o, "%s/%s" % (localdir, filename))
print "%s/%s" % (localdir, filename)
main(sys.argv[1], sys.argv[2])
@rhiaro
Copy link
Author

rhiaro commented Mar 23, 2016

run python files_from_solid.py path/to/local https://user.databox.me/path/to/files/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment