0
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

posted at

dbpediaの研究 その29

概要

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();


成果物

以上。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
0
Help us understand the problem. What are the problem?