7-2 網??????????

bW`Aڭ̤ФF LWP::Simple ΪkMdҡCϥ LWP::Simple ӧ۷KAO]@ǯIG
  1. bL{ALkǷ|AX]Status Code^C`AXUCXءG

    AX
    200OKA@`
    404䤣ҭnD
    408ݦA^ЮɶL[
    500AoͿ~

  2. Perl {ä|bY]Header^VAۤvC
  3. 䴩NzA]Proxy Server^C
]AYnonDAXANnϥθҲաCHUoӨҤlAiHP_O_\AY\AhLXlXFY\AhLX~TC{X]tstatus.pl^pUG

lɡ]tstatus.pl^G]ǦϰUYi^
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;

$ua = new LWP::UserAgent;				#  UserAgent 
$request = new HTTP::Request('GET', $ARGV[0]);	#  Request 
$response = $ua->request($request);			# }lAñNGǷ| $response
if ($response->is_success) {			# Y\AhLX HTML lX
	print $response->content;
} else {						# Y\AhLX~T
	print $response->error_as_HTML;
}

Uoӽdҡ]tproxy.pl^AhϥΤF HTTP NzAӴֺyqG

lɡ]tproxy.pl^G]ǦϰUYi^
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;

$ua = new LWP::UserAgent;				#  UserAgent 
$ua->proxy('http', 'http://proxy.nthu.edu.tw/proxy.pac');	# ]w HTTP NzA
$ua->no_proxy('nthu.edu.tw');			# bMj]nthu.edu.tw^ϥΥNzA
$request = new HTTP::Request('GET', $ARGV[0]);	#  Request 
$response = $ua->request($request);			# }lAñNGǷ| $response
if ($response->is_success) {			# Y\AhLX HTML lX
	print $response->content;
} else {						# Y\AhLX~T
	print $response->error_as_HTML;
}

ܦAŪӥiHP Perl ӧKQʻPuʡCyLקWzdҵ{ANiHͳ\hPΡAHUO@ǦΡ]Φ^νdҡG


Perl