|
Posted by ifiaz on March 8, 2008, 10:34 am
Please log in for more thread options Also, please so you know,
my $baseurl =
'http://www.bangkokflightservices.com/our_cargo_track&trace.php';
my $hawb = 'h_prefix=HAWB&h_sn=';
h_prefix should be HWB and not HAWB.
I have fixed that in my code and still the same problem that it throws
me to a different page.
> You may need to adjust the follow_link call if there are several links
> on
> the same page that match that regex; see perldoc WWW::Mechanize for
> the
> arguments. If the server checks the Referer, you may also need to ->get
>
> /our_cargo_track.php first.
>
> Ben
> ----
>
> Thank you for your prompt response.
>
> When I used the code with minor modifications, I still have the
> problem that I can't access the data as the process throws me to
> another page as below.
>
> This is what the $content contains:
>
> <script> window.open ('http://www.bangkokflightservices.com/
> our_cargo_track.php') ;
> setTimeout("window.close();", 10);
> </script>
>
> How to get to the actual data page. Please guide me here as I am a
> newbie.
>
> I don't know how to implement Referer and all that.
>
> ### This is the complete code I used.
> #!/usr/bin/perl
>
> use WWW::Mechanize;
>
> my $baseurl =
> 'http://www.bangkokflightservices.com/our_cargo_track&trace.php';
> my $hawb = 'h_prefix=HAWB&h_sn=';
>
> my $M = WWW::Mechanize->new(auto_check => 1);
>
> ## Added code for testing Only
> my $F = WWW::Mechanize->new(auto_check => 1);
> $F->get("http://www.bangkokflightservices.com/our_cargo_track.php");
> my $contentF = $F->content;
> #print "$contentF\n";
> #$M->add_header("Referer => 'http://www.bangkokflightservices.com/
> our_cargo_track.php'" )
>
> while (<>) {
> chomp;
>
> my ($mprefix, $msn) = /(...)-(........)/ or do {
> warn "invalid MAWB: '$_'";
> next;
> };
>
> print "$mprefix $msn\n";
>
> $M->get("$baseurl?m_prefix=$mprefix&m_sn=$msn&$hawb");
> $M->follow_link(url_regex => qr/showc_track/);
> my $content = $M->content;
>
> print "$content\n"; # for debugging
>
> # process $content as before
> #
> while ( $content =~ m#(.*)#g ) {
> $currline=$1;
>
> if ($currline =~ m#style12#i) {
>
> $currline =~ m#.*>(.*?)<.*#i;
> $result = $result . " / " . $1;
> }
> }
> print "***$result\n";
> $result = '';
>
> }
|