First, I want to note for the benefit of anyone who has had to deal with a cantankerous web server that, if it only wants to server to Internet Explorer clients, it may help to code like this:
my $a = WWW::Mechanize->new(autocheck => 1, agent => 'Mozilla/4.0 (compatible; MSI +E 6.0; Windows NT 5.0; T312461)', keep_alive=> 1); my @silly_headers = ('Accept-Language' => 'en-us', 'Accept-Encoding' => 'gzip, deflate', 'Accept' => '*/*'); $a->get($testpage, @silly_headers);
That solved the problem that I was having in Mechanize and "Not implemented".

Now, for the new puzzler, which is not a Perl problem, per se, but which I hope has a Perl solution: There is a secure web site that I can access via browser, but when I try to get to the login page via WWW::Mechanize, I get a failure. Unlike my previous problem, this website is public. However, the problem is most likely tied to the proxy server, so there's still going to be some difference when you run it vs. when I do.

While the error message appears to come from the proxy, I note that I do not have a problem in accessing the site, via the same proxy, from a browser. Very odd.

Here's the script:

#!perl # Automated navigation through web pages use strict; use warnings; use WWW::Mechanize; my $testpage='https://www.openinvoice.com/docp/login/login.jsp'; my $teststring = 'Oilfield Commerce Platform (TM) Login'; $testpage = 'http://www.openinvoice.com'; $teststring = 'login now'; my $a = WWW::Mechanize->new(autocheck => 1, agent => 'Mozilla/4.0 (compatible; MSI +E 6.0; Windows NT 5.0; T312461)', keep_alive=> 1); $a->proxy(['http', 'https'], 'http://www-proxy:8080/proxy.pac'); my @silly_headers = ('Accept-Language' => 'en-us', 'Accept-Encoding' => 'gzip, deflate', 'Accept' => '*/*'); $a->get($testpage, @silly_headers); $a->success() or die "Failed to get $testpage: ".$a->status()."\n".$a- +>res()->as_string()."\n"; my $link = $a->find_link( text => 'login now.' ) or do { warn "Did not find link\n"; warn "Link: ". $_->[1] .' -> '. $_->[0] ."\n" for $a->links(); }; #use Data::Dumper; #die Dumper($link), "\n"; $a->get($link->[0], @silly_headers); $a->success() or warn "Followed link to ", $a->base, "\n"; $a->success() or die "Failed to get ".($a->base).': '.$a->res()->as_st +ring()."\n"; print "Page is ", $a->content, "\n";
And the output I get:
Followed link to https://www.openinvoice.com/docp/corp/main/login Failed to get https://www.openinvoice.com/docp/corp/main/login: HTTP/1 +.0 500 (Internal Server Error) Error from proxy Content-Type: text/html Client-Date: Fri, 28 Nov 2003 18:05:11 GMT Client-Peer: 148.89.144.220:8080 Client-Response-Num: 1 Mime-Version: 1.0 Proxy-Agent: iPlanet-Web-Proxy-Server/3.6 Title: Error <HTML> <HEAD><TITLE>Error</TITLE></HEAD> <BODY> <H1>Error</H1> <BLOCKQUOTE><B> <HR SIZE=4><P> The requested item could not be loaded by the proxy.<P> The certificate issuer for this server is not recognized by Netscape. The security certificate may or may not be valid. Netscape refuses to connect to this server.<P> <HR SIZE=4> </B></BLOCKQUOTE> <P> <ADDRESS>Proxy server at flash.sugarland.unocal.com on port 8080</ADDR +ESS> </BODY></HTML>

The PerlMonk tr/// Advocate

In reply to More Mechanize Woes by Roy Johnson

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.