I am using www::mechanize to log in to a user account and make a search of the db. This has been a straightforward task in the past, I simply create a GET query using a search form, send it to my script, the query is then appended to a url which retrieves the search results to my script and I carry on from there.

However now when I use this method there is a database error:

Microsoft VBScript runtime error '800a000d' Type mismatch: 'EndSQLDate' C:\WWWROOT\CUSTOMERS\K-O\MY\AGENT\../searchresults.asp, line 683
so I cannot retrieve the results.

The strange thing (to me) is that when I use exactly a query which retrieves results when using a browser to log in and search and append that as a query to my script, I get the error. This seems to indicate that the behavior of the browser generated by WWW::Mechanize is not the same as the browser on my computer, and whatever is the difference is having a negative consequence.

Is there some changes I could try to try to emulate better the browser or does anyone have an idea about how I can prevent this error? (By the way, the fact of getting the error demonstrates that log in was successful!)

sub new { my ( $this,$id ) = @_; my $ua = LWP::UserAgent->new(timeout => 90,agent=> 'User-Agent +=Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.5) G +ecko/20091102 Firefox/3.5.7'); $ua->cookie_jar( HTTP::Cookies->new('file' => 'cookies.txt' +,'autosave'=>1)); $ua->conn_cache(LWP::ConnCache->new()); #$ua->show_progress(1); push @{ $ua->requests_redirectable }, 'POST'; my $self = {id=>$id, ua=>$ua}; }); bless $self, __PACKAGE__; }
sub getsearchresults{ my $self = shift; $self->login; my $query = $ENV{'QUERY_STRING'}; my $searchurl = 'https://secure.url.net/agent/loadsearchresults.as +p?' . $query; my $res; $res = $self->{ua}->get($searchurl)->content; print $res; exit; }

In reply to www::mechanize not behaving as browser? by jonnyfolk

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.