Since dbpedia is esoteric, I'll try it. I tried to get it with java.
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
public class Main {
public static String sendGet(String url, String param) {
String result = "";
BufferedReader in = null;
try
{
String urlNameString = url + "?" + param;
URL realUrl = new URL(urlNameString);
URLConnection connection = realUrl.openConnection();
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36");
connection.connect();
Map<String, List<String>> map = connection.getHeaderFields();
for (String key : map.keySet())
{
System.out.println(key + "--->" + map.get(key));
}
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = in.readLine()) != null)
{
result += line;
}
}
catch (Exception e)
{
System.out.println("err!" + e);
e.printStackTrace();
}
finally
{
try
{
if (in != null)
{
in.close();
}
}
catch (Exception e2)
{
e2.printStackTrace();
}
}
return result;
}
public static void main(String[] args) throws Exception {
Main httpTest = new Main();
String query = "query=" + URLEncoder.encode("SELECT DISTINCT * WHERE { dbpedia-ja:De Tomaso dbpedia-owl:abstract ?abstract .}", "UTF-8");
System.out.println(httpTest.sendGet("http://ja.dbpedia.org/sparql", query));
}
}
https://paiza.io/projects/f2-WNirCplt9PQAH3XeK4g
that's all.
Recommended Posts