LoginSignup
1
0

More than 1 year has passed since last update.

SWI-Prolog の http クライアントの使い方 (Get)

Last updated at Posted at 2018-10-15
http_get.pl
/* ------------------------------------------------------------------- */
/*
	http_get.pl

						Feb/28/2020
*/
/* ------------------------------------------------------------------- */
:- use_module(library(http/http_open)).

:- initialization main.
main() :-
	format('*** 開始 ***\n'),
	Url_in = 'https://httpbin.org/get',
	http_open(Url_in, In, []),
	copy_stream_data(In,user_output),
	close(In),
	format('*** 終了 ***\n'),
	halt.
/* ------------------------------------------------------------------- */

実行結果

$ swipl -f ./http_get.pl
*** 開始 ***
{
  "args": {}, 
  "headers": {
    "Host": "httpbin.org", 
    "User-Agent": "SWI-Prolog", 
    "X-Amzn-Trace-Id": "Root=1-5e58b488-4687f8c67b3200f25fe2155c"
  }, 
  "origin": "153.233.38.78", 
  "url": "https://httpbin.org/get"
}
*** 終了 ***

確認したバージョン

$ swipl --version
SWI-Prolog version 9.0.4 for x86_64-linux
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