So I have been trying to learn LWP Post, by going through a examples on the web. Except it seems like every example on the web, the page no longer exists (well specifically the page that I am supposed to post to)... I am hoping someone could tell me what I am doing wrong as I try to modify this example for
Perl & LWP.
I am attempting to search AbeBooks for the book "Codex Seraphinianus" from the main page (AbeBooks). Here is the code that I am using:
#!/usr/bin/perl -w
use strict;
use LWP;
my $browser = LWP::UserAgent->new( agent => 'Mozilla/5.0 (Windows; U;
+Windows NT 6.0; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0' );
$browser->cookie_jar({});
my $response = $browser->post(
'http://www.abebooks.com/servlet/SearchEntry',
# That's the URL that the real form submits to.
[
"bi" => "0",
"bx" => "off",
"ds" => "30",
"sortby" => "2",
"sts" => "t",
"tn" => "Codex+Seraphinianus",
"x" => "43",
"y" => "10",
]
);
print $response->content;
But this just sends me back the content of the
advanced search page not the
results page. I guess I really have two questions,
1) Is there a way to check the http header that goes to the request? I want to check the header versus when I do it in the Firefox browser (with the idea that will help me debug my code in the future)
2) How do I fix my code to get back to the proper results page?
Updated For what it is worth, there is JavaScript on the page, so that is a fun kick in the pants...
Cheers
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.