Dear expert - I try to use the code as below to get the website htm source and it works. However, I cannot get the result when I visit the website http://reserve.apple.com/WebObjects/ProductReservation.woa/wa/reserveProduct by using code as below. But, I can access this page by using browser properly. Would you give me some hints or tips to fix this problem? Thank you.

#!/usr/bin/perl

use strict;
use warnings;

# create a new browser
use WWW::Mechanize;
my $browser = WWW::Mechanize->new();

# tell it to get the main page

my $sURL = 'http://www.apple.com';

#my $sURL = 'http://reserve.apple.com/WebObjects/ProductReservation.woa/wa/reserveProduct';

$browser->get($sURL);

print $browser->content;

exit(0);

You can try by setting the user-agent.

use WWW::Mechanize;
my $mech=WWW::Mechanize->new();
$mech->agent_alias( 'Windows IE 6' );

For more list of user agents try - perldoc WWW::Mechanize
Also see this page for known issues.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.