I want to have a Perl script which will act as HTTP client. Basically, it should be able to get (read) a given HTML page from server.
I have this code with me,
Expand|Select|Wrap|Line Numbers
- # ------------------------------------
- use IO::Socket;
- $host = "www.cs.cf.ac.uk" ; ## Use any site here
- $document = "index.html" ;
- $BLANK = "\n\n\n" ;
- $remote = IO::Socket::INET->new( Proto => "tcp",
- PeerAddr => $host,
- PeerPort => "http(80)",
- );
- unless ($remote) { die "cannot connect to http daemon on $host" }
- print "Socket object created\n" ;
- $remote->autoflush(1);
- print "Autoflush done\n" ;
- print $remote "GET $document HTTP/1.0" . $BLANK;
- print "Request written\n" ;
- while ( <$remote> ) { print }
- close $remote;
- # ---------------------------------------------
What can be the issue ??
Please help.
Thanks