Wolfram Language

Request Linked Data from a Website

Websites usually respond with "human-readable" content when a browser makes a request (on behalf of a "human"). To extract the data for further processing, one can request "machine-readable" data instead.

Version 12 introduces support for various RDF (Resource Description Framework) Import and Export formats, including "JSONLD" (a format based on "JSON", where "LD" hints at "Linked Data"). One can request linked data by specifying an appropriate "accept" header in an HTTPRequest.

This example imports track information from an album of the famous tango orchestra leader Francisco Canaro from MusicBrainz.

Start by navigating to an album of your choice, say by using the search box and clicking links in your browser. Once you find an interesting album, copy the URL and store it in a variable.

That is what the website would look like in a browser.

To request linked data, create an HTTPRequest that specifies the JSON-LD media type in its "accept" header.

Execute the request and import the response using the "JSONLD" importer.

The result is an RDFStore object that contains information pertaining to this album. Now apply the SPARQLQuery operator to retrieve all properties used in the store.

Write a query that requests, for all tracks, the track number and name.

Here is an example track.

The track numbers are strings of the format disk.track. Extract track and convert it to an "Integer" so you can sort by "number" numerically.

Display a Dataset, showing only track number and title.

Related Examples

de es fr ja ko pt-br zh