Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automated form entry (post request) using lwp

Status
Not open for further replies.

gupta3

Programmer
Joined
Jul 20, 2006
Messages
2
Location
US
Hi,

I am trying to do a simple post request which is just not working. I just need a working example of something simple and then I will be able to hopefully imitate it for other forms I'm using. For example, does anyone know why the following is not working for me? I'm just getting the page with the form, not the result page. I tried both the URL that is enabled below as well as the commented out one. Thanks a lot for any help!

Code:
use LWP;
my $browser = LWP::UserAgent->new;
$browser->cookie_jar({});

my $url = '[URL unfurl="true"]http://www.fjc.gov/public/home.nsf/hisj';[/URL]
#my $url = '[URL unfurl="true"]http://www.fjc.gov/history/home.nsf/search_db_sybase!OpenForm&Seq=1&BaseTarget=right';[/URL]

my $response = $browser->post
(
  $url,
        [
          '_Click' => '0',
          'name' => 'posner'
        ]
);

die "$url error: ", $response->status_line unless $response->is_success;

print $response->content;
 
Normally using LWP, I'd pass the variables in the QUERY_STRING using a get, and it seems to work OK.

I'm just wondering about the form on the page, if there's more than one?

--Paul

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Thanks for the help Paul - I'm not too sure what you mean. Do you mean just use the get function on the following URL for the above example?

This is the URL that shows up when I search for posner. There aren't any other forms on the page (you can see it at The one thing is that I want to be able to do the post form way of doing it also, as that might be easier for other form entries - primarily, I'm trying to do a search for legal cases on LexisNexis Academic, but first I have to log in to do this, and then do the search, and I need to log in using the post request LWP has, I'm pretty sure, and then I can do the search I want using the Perl post request again. Any thoughts?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top