Hi monks
I am trying to retrieve a certain web page with search results with the LWP::UserAgent. I took the URL query from this web site after conducting a search for cats and changing the form from POST to GET, using Firefox. This is the code:
#!/exlibris/metalib/m4_b/product/bin/perl use strict; use LWP::UserAgent; { my $ua = new LWP::UserAgent(); my $search_address = "http://www.stat-usa.gov/nct_all.nsf/2d58b7a 34bbaa3838525703f004f804e?"; my $post = 'qAllWords=cats&qAnyWords=&qNoWords=&PostedSince=01%2F0 +1%2F2003&webcat_select=All&databases=ATL&databases=AGWORLD&databases= +MRD_CCG&databases=DLA&databases=CBD&databases=MRD_ISA&databases=MRD_I +MI&databases=MISCFILES&databases=MRD_ALL&databases=MRD_MDB&databases= +NED&databases=PUB&databases=ONLINE&databases=TOP&databases=ETO_DE&dat +abases=ETO_OF&configserver=CN%3Dstatweb01%2FOU%3Dwebserv%2FOU%3Dstate +sa%2FO%3Dstatdoc&configpath=nct_config5.nsf&webcategories=All&header= +&footer=&disp_header=&disp_footer=&saveoptions=0&query=AND+%28%5BdUpd +ate%5D+%3E+01%2F01%2F2003%29'; #creating the request object my $header = new HTTP::Headers(); my $req = new HTTP::Request ('POST', $search_address, $header, $po st); #sending the request my $res = $ua->request($req); if (!($res->is_success)){ warn "Warning:".$res->message."\n"; } print $res->as_string."\n"; }
However, when I run this program, instead of getting the search results, I get the search page. Usually when this happens it is because of a cookie, but I couldn't find any cookies in this site. Does anybody know what the problem might be, and how I can solve it by retrieving the search results page?
Much obliged
Guy Naamati

"A truth that's told with bad intent beats all then lies you can invent"

In reply to Retrieving web pages with the LWP::UserAgent by mrguy123

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.