Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Retrieving web pages with the LWP::UserAgent

by b10m (Vicar)
on Sep 06, 2006 at 13:26 UTC ( #571454=note: print w/replies, xml ) Need Help??


in reply to Retrieving web pages with the LWP::UserAgent

When I convert the POST to a GET, I get an error:

Error 400: 

HTTP Web Server: Unknown Command Exception

So my guess is that they really want you to POST your data.

For such tasks, WWW::Mechanize is usually my preferred choice, for it makes stuff so easy. A sample script like this would get you started:

use strict; use WWW::Mechanize; my $mech = new WWW::Mechanize; $mech->get('http://www.stat-usa.gov/nct_all.nsf/Search'); $mech->submit_form( form_name => '_Search', fields => { Query => 'your search term', } ); print $mech->content;
--
b10m

All code is usually tested, but rarely trusted.

Replies are listed 'Best First'.
Re^2: Retrieving web pages with the LWP::UserAgent
by mrguy123 (Hermit) on Sep 06, 2006 at 13:32 UTC
    Thanks for the advice. Does it work similarly to the LWP::UserAgent?

      It uses LWP::UserAgent, yes, only (as you can see), it a lot easier to work with. The code above is basically all you need ;-)

      --
      b10m

      All code is usually tested, but rarely trusted.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://571454]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2022-12-08 01:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?