Quantcast
Channel: Node.jsタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 8832

dbpediaの研究 その29

$
0
0

概要

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


成果物

https://paiza.io/projects/5UX0bQUGTI0Ao7rD9wEyPA

以上。


Viewing all articles
Browse latest Browse all 8832

Trending Articles