Created
March 20, 2016 22:03
-
-
Save anarchivist/b3bbcdd132acb0a9a1bc to your computer and use it in GitHub Desktop.
Using HTTP Basic authentication to fetch resources in a Fedora 4 demo install for parsing with RDFLib
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
| import urllib2 | |
| from rdflib import Graph, URIRef, Literal | |
| # Register an authentication handler | |
| auth_handler = urllib2.HTTPBasicAuthHandler() | |
| auth_handler.add_password(realm='fcrepo', uri="http://localhost:8080/fcrepo/rest", user="fedoraAdmin", passwd="secret3") | |
| opener = urllib2.build_opener(auth_handler) | |
| urllib2.install_opener(opener) | |
| # Create a new rdflib Graph object and parse the remote resource | |
| g = Graph() | |
| g.parse("http://localhost:8080/fcrepo/rest/cover") | |
| # <Graph identifier=N9e321401ad4346cf888708c01c7e91e7 (<class 'rdflib.graph.Graph'>)> | |
| for _ in g: | |
| print _ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment