小目次

目次にもどる
ープログラム
ー実行結果

課題4:HTTPクライアントの作成

ソケットおよびHTMLを使ってWWWサーバから任意のURLのページを取得し、標準出力に出力するプログラムを作成せよ。

プログラム

http_client.cのソースコード(別ウィンドウ)
関数については関数メモを参照

実行結果

%http_client http://rikujyo3ka.com/ | nkf -euc
http://rikujyo3ka.com/ を取得します。

GET / HTTP/1.0
Host: rikujyo3ka.com:80

HTTP/1.1 200 OK
Date: Mon, 04 Dec 2006 01:05:12 GMT
Server: Apache/1.3.33 (Unix) PHP/4.3.10
Last-Modified: Mon, 27 Nov 2006 12:37:17 GMT
ETag: "d8141-2f78-456adbfd"
Accept-Ranges: bytes
Content-Length: 12152
Connection: close
Content-Type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="株式会社ゴンゾ,株式会社GDH,テレビアニメーション,パンプキン・シザーズ,パンプキン,シザーズ,pumpkin scissors,南瓜鋏,陸情3課広報室">
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS" />
<title>陸情3課広報室-Pumpkin Scissors-</title>
<link href="ps.css" rel="stylesheet" type="text/css" />
<style type="text/css">
上にもどる
目次にもどる