1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

paiza.ioでelixirAdvent Calendar 2022

Day 4

paiza.ioでelixir その79

Last updated at Posted at 2022-11-18

概要

paiza.ioでelixirやってみた。
dbpediaのsparqlを叩いてみた。

サンプルコード

:inets.start
:ssl.start

query = URI.encode_query(%{query: """

SELECT DISTINCT * WHERE {<http://ja.dbpedia.org/resource/東京都> ?p ?o . } LIMIT 3

"""})
#|> IO.inspect
{:ok, {{_, _, _}, _, body}} = :httpc.request(:post, {
	'https://ja.dbpedia.org/sparql', 
	[{'Accept', 'application/sparql-results+json'}], 
	'application/x-www-form-urlencoded', 
	query
}, [], [])
#|> IO.inspect
body = IO.iodata_to_binary(body)
IO.puts(body)


実行結果


{ "head": { "link": [], "vars": ["p", "o"] },
  "results": { "distinct": false, "ordered": true, "bindings": [
    { "p": { "type": "uri", "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" }	, "o": { "type": "uri", "value": "http://www.w3.org/2002/07/owl#Thing" }},
    { "p": { "type": "uri", "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" }	, "o": { "type": "uri", "value": "http://dbpedia.org/ontology/AdministrativeRegion" }},
    { "p": { "type": "uri", "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" }	, "o": { "type": "uri", "value": "http://schema.org/Place" }} ] } }

成果物

以上。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?