#!/usr/bin/perl # @(#) Usage : httpget.pl # @(#) Example : httpget.pl # @(#) Copyright (C) 2002, Web Sailor Production, All Rights Reserved. # @(#) 19Jan02 - sailor, Initial creation. # @(#) This is a useful example showing how to get # @(#) an HTML page using perl script. use HTTP::Headers; use HTTP::Request; use LWP::UserAgent; # Thr Browser $ua = new LWP::UserAgent; $ua->agent("Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)"); # The following line is only needed if you are accessing the # the internet from behind the firewall. # $ua->proxy("http","http://webproxy0.ops.sing.paging.mot.com:1080/"); # The GET method $url = "http://www.yahoo.com/"; # The following lines are only needed if you are accessing the # the internet from behind the firewall. # Note that the authorization string is dependent on your login and # password. It is base 64 encoded. For example, if my login is sailor # and password is cool. The MIME code of "sailor:cool" is # "c2FpbG9yOmNvb2w=". Please refer to http://www.khngai.com/tools/base64.php. # $header = new HTTP::Headers("Proxy-authorization" => "basic c2FpbG9yOmNvb2w="); # $request = new HTTP::Request("GET",$url,$header); $request = new HTTP::Request("GET",$url); $response = $ua->request($request); print $response->headers_as_string(); print ("\n\n"); print $response->content;