Skip to content

Instantly share code, notes, and snippets.

@acdha
Created June 11, 2013 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acdha/4ba5286f9f872f771ea6 to your computer and use it in GitHub Desktop.
Save acdha/4ba5286f9f872f771ea6 to your computer and use it in GitHub Desktop.
Failed attempts at loading RDFa data
(rdflib)cadams@Io:~/Desktop $ pip install 'rdflib<4'
Downloading/unpacking rdflib<4
Using download cache from /tmp/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fr%2Frdflib%2Frdflib-3.4.0.tar.gz
(rdflib)cadams@Io:~/Desktop $ ./rdf-test.py 'http://www.bbc.co.uk/news/world-us-canada-22857062' 'http://oreilly.com/catalog/9780596804251/'
Loading 2 resources using rdflib 3.4.0
Loading 'http://www.bbc.co.uk/news/world-us-canada-22857062'
ERROR: RDFa parsing Error!
Loading 'http://oreilly.com/catalog/9780596804251/'
ERROR: RDFa parsing Error! 'ascii' codec can't decode byte 0xc3 in position 7291: ordinal not in range(128)
(rdflib)cadams@Io:~/Desktop $ pip uninstall -y rdflib
Uninstalling rdflib:
Successfully uninstalled rdflib
(rdflib)cadams@Io:~/Desktop $ pip install 'rdflib'
Downloading/unpacking rdflib
Using download cache from /tmp/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fr%2Frdflib%2Frdflib-4.0.1.tar.gz
(rdflib)cadams@Io:~/Desktop $ ./rdf-test.py 'http://www.bbc.co.uk/news/world-us-canada-22857062' 'http://oreilly.com/catalog/9780596804251/'
Loading 2 resources using rdflib 4.0.1
Loading 'http://www.bbc.co.uk/news/world-us-canada-22857062'
ERROR: RDFa parsing Error!
Loading 'http://oreilly.com/catalog/9780596804251/'
ERROR: RDFa parsing Error! 'ascii' codec can't decode byte 0xc3 in position 7291: ordinal not in range(128)
(rdflib)cadams@Io:~/Desktop $
#!/usr/bin/env python
import sys
import rdflib
if len(sys.argv) < 2:
print >>sys.stderr, "Usage: %s url_or_file ..." % sys.argv[0]
sys.exit(1)
print "Loading %d resources using rdflib %s" % (len(sys.argv) - 1, rdflib.__version__)
for i in sys.argv[1:]:
print "Loading '%s'" % i
try:
g = rdflib.Graph()
g.parse(i)
print "... loaded %d records" % len(g)
except Exception as e:
print >>sys.stderr, "ERROR: %s" % e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment