[EMAIL PROTECTED] wrote: > > $html has nothing from the following code. Could someone help me? > Thanks.
Always use strict; use warnings; and declare all your variables with 'my'. That way you can fix many coding errors yourself without having to ask for help. > use LWP; > use URI; You don't use the URI module. > $Browser = LWP::UserAgent->new || die "$!"; There is little point in checking whether Perl could create the LWP::UserAgent object. Something hideous is wrong if it fails, and the reason certainly won't be in the $! variable. > my $Surfurl = 'http://us.randstad.com/webapp/internet/servlet/ > BranchView?b=702'; > my @ns_headers = ( > 'User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; > rv:1.8.1.11) Gecko/20071127', > 'Accept' => 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, > image/png, */*', > 'Accept-Charset' => 'iso-8859-1,*,utf-8', > 'Accept-Language' => 'en-US', > ); > > my $response = $Browser->get( $Surfurl, @ns_headers ); > die "Can't get $url -- ", $response->status_line unless $response- >> is_success; There is no such variable as $url. Errors like this would be caught if you had used strict as above. > die "Hey, I was expecting HTML, not ", $response->content_type unless > $response->content_type eq 'text/html'; > > my $html = $response->decoded_content; my $html = $response->decoded_content(raise_error => 1); will cause the call to give you an error message showing any reason for failure. I suggest you use just my $html = $response->content; > print $html; > print "program finished"; Over all I wonder why you've gone to such lengths to do something very simple. The program below works fine and seems to do what you want. HTH, Rob use strict; use warnings; use LWP; my $ua = LWP::UserAgent->new; my $url = 'http://us.randstad.com/webapp/internet/servlet/BranchView?b=702'; my $response = $ua->get($url); print $response->content; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/