LoginSignup
0
0

More than 3 years have passed since last update.

dbpediaの研究 その29

Posted at

概要

dbpediaが難解なので、手出してみる。
node.jsで、取得してみた。

サンプルコード

process.stdin.resume();
process.stdin.setEncoding('utf8');

var http = require('http');
const querystring = require('querystring');

const HOST = 'ja.dbpedia.org';
const PATH = '/sparql';
let postData = {
    'query': 'SELECT DISTINCT * WHERE { dbpedia-ja:デ・トマソ dbpedia-owl:abstract ?abstract .}'
};
let postDataStr = querystring.stringify(postData);
let options = {
    host: HOST,
    port: 80,
    path: PATH,
    method: 'POST',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Content-Length': postDataStr.length
    }
};
let req = http.request(options, (res) => {
  res.setEncoding('utf8');
  res.on('data', (chunk) => {
    console.log(chunk);
  });
});
req.on('error', (e) => {
  console.log('problem with request: ' + e.message);
});
req.write(postDataStr);
req.end();


成果物

以上。

0
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
0
0