http://www.perlmonks.org?node_id=925843

boeingdream has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I would like to visit a web page, get its http response, and print it. I tried following code, but it's always timeout.

#! /usr/perl/bin use warnings; use strict; use LWP::Simple; my $page_content = get("http://hq.sinajs.cn/list=sh601006"); unless (defined $page_content) { die "doc content is not undef\n"; } print $page_content,"\n";

Besides, I found that, in LWP::Simple, the function _trivial_http_get() cannot build socket connection to target website and return with undef every time.

my $sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port, Proto => 'tcp', Timeout => 30) || return undef;

$port is 80 by default.

Thank you very much for your time.