blob: 30462541a05dca488234538ca4a9e56d8a3de287 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
"""
A simple example showing how to process RDFa from the web
"""
from rdflib import Graph
if __name__ == "__main__":
g = Graph()
g.parse(
"https://www.worldcat.org/title/library-of-babel/oclc/44089369", format="rdfa"
)
print("Books found:")
for row in g.query(
"""SELECT ?title ?author WHERE {
[ a schema:Book ;
schema:author [ rdfs:label ?author ] ;
schema:name ?title ]
FILTER (LANG(?title) = 'en') } """
):
print("%s by %s" % (row.title, row.author))
|