Hi, I am using Mechanize module to automate log-in to a web page. The code that I have written is
use WWW::Mechanize; use Log::Log4perl qw(:easy); Log::Log4perl->easy_init($ERROR); # The starting point URL my $start_url = "http://***.**.**.*:****"; my $ret_val; my $redir_pattern = 'HTTP-EQUIV="Refresh"\s*CONTENT="0;URL='; my @temp_array; my $redir_url; # Create a new instance of WWW::Mechanize my $agent = WWW::Mechanize->new(); # Retrieve the page $agent->get($start_url); my $content = $agent->content(); print $content; my @links = $agent->find_all_links(); print $#links;
The output that I am getting is,
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Inventum - Service Selection Gateway</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +"> <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"/> <META HTTP-EQUIV="EXPIRES" CONTENT="-1"/> <META HTTP-EQUIV="Refresh" CONTENT="0;URL=http://***.**.**.*:****/ssgu +sercgi/login.ssg?ip=***.**.**.*:****&mac=**:**:**:**:**:**&requestip= +***.**.**.*&requesturi=http%**%**%*****.**.**.*%******%**"> </head> <body> <p align="center">Please wait...<p> </body> </html> -1
Please note that the HTML contains <META HTTP-EQUIV="Refresh" which find_all_links is not recognizing, as print $#links; is returning -1. Am I doing anything wrong there? Please help... regards Gator

In reply to Mechanize not recognizing link in <META HTTP-EQUIV="Refresh" by gator

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.