LWP problem...
Chris Hobbs (chobbs@silvervalley.k12.ca.us)
Fri, 11 Dec 1998 11:46:22 -0800
[ Reposted here on recommendation from Perl-Win32-WWW]
Hello Everyone!
I'm writing a little script for our purchasing department (and myself,
of course) to find the best pricing on books from the big three online
vendors, Amazon, Borders, and Barnes and Noble.
The script takes an ISBN and hits each vendor's site for that book,
parses out the pricing info, and sends it back to the user's browser.
I've used a script that Randall Schwartz has on his website for pulling
Dilbert strips from unitedmedia.com as a model.
It works splendidly with Amazon and Borders; however, I'm having
problems with B&N. In order to discover whether the problem was with my
RegEx or not, I modified the code so that it looks like the following
(lots removed for clarity...)
1: use strict;
2: use LWP::Simple qw/get/;
3: use CGI qw/:form :html param header/;
4:
5: my $b_and_n_top =
"http://shop.barnesandnoble.com/bookSearch/isbnInquiry.asp?isbn=";
6: my $isbn = param("isbn");
7:
8: my $b_and_n_page = get ($b_and_n_top . $isbn);
9: print p("B & N Page should begin here...");
10: print $b_and_n_page; # TEST TO MAKE SURE PAGE IS RETRIEVED!
11: print p("...and it should stop here!");
The problem is that line 10 prints only half the time
(approximately...), and thus I can't parse the price. However, whenever
I click the link I create, it works perfectly. You may try the script at
http://www.silvervalley.k12.ca.us/autopilot/books.pl?isbn=1565922433
The complete listing is at:
http://www.silvervalley.k12.ca.us/autopilot/books.pl.txt
I know it's sort of ugly (I'm new, OK? :-), but I am impressed that it
works so well for what I've learned so far. If I can just figure out why
I can't load in that B & N page, it'll be wonderful.
Thanks for your help,
Chris Hobbs