use HTTP::Request;
use HTTP::Request::Common;
use HTTP::Response;
+use HTML::Entities;
our(@warn);
our(@fault);
sub cart_add (@) {
my (@orderlist) = @_;
my ($i, $url, $item, $qty, @submit, $request, $response);
- $url= "$urlbase/jsp/op/shoppingbasket.jsp;jsessionid=$jsessionid".
- "?_DARGS=/jsp/home/quickbuycontent.jsp";
- @submit= (
-#_DARGS => "/jsp/home/quickbuycontent.jsp",
-
-'_dyncharset' => 'ASCII',
-#'/pf/commerce/PFCartHandler.setOrderSuccessURL' => '/jsp/op/shoppingbasket.jsp',
-#'_D:/pf/commerce/PFCartHandler.setOrderSuccessURL' => ' ',
-#'/pf/commerce/PFCartHandler.setOrderErrorURL' => '/jsp/op/shoppingbasket.jsp',
-#'_D:/pf/commerce/PFCartHandler.setOrderErrorURL' => ' ',
-'/pf/commerce/PFCartHandler.addLinesSuccessURL' => '/jsp/op/shoppingbasket.jsp',
-'_D:/pf/commerce/PFCartHandler.addLinesSuccessURL' => ' ',
-#'/pf/commerce/PFCartHandler.moveToPurchaseInfoErrorURL' => '/jsp/op/shoppingbasket.jsp',
-#'_D:/pf/commerce/PFCartHandler.moveToPurchaseInfoErrorURL' => ' ',
-#'/pf/commerce/PFCartHandler.addPotentialProductsSuccessURL' => '/jsp/op/shoppingbasket.jsp',
-#'_D:/pf/commerce/PFCartHandler.addPotentialProductsSuccessURL' => ' ',
-#'/pf/commerce/PFCartHandler.addPotentialProductsErrorURL' => '/jsp/op/shoppingbasket.jsp',
-#'_D:/pf/commerce/PFCartHandler.addPotentialProductsErrorURL' => ' ',
-#'/pf/commerce/PFCartHandler.fowardOrderSuccessURL' => '/jsp/op/forwardmultistageorder.jsp',
-#'_D:/pf/commerce/PFCartHandler.fowardOrderSuccessURL' => ' ',
-#'/pf/commerce/PFCartHandler.moveToPurchaseInfoSuccessURL' => 'https://secure.farnell.com/jsp/op/shipping.jsp;jsessionid=UPTT45ICG5DERQFIAEXSFE4AVAAS4IV3',
-#'_D:/pf/commerce/PFCartHandler.moveToPurchaseInfoSuccessURL' => ' ',
-'/pf/commerce/PFCartHandler.setOrderByCommerceId.x' => '0',
-'/pf/commerce/PFCartHandler.setOrderByCommerceId.y' => '0',
-'_D:/pf/commerce/PFCartHandler.setOrderByCommerceId' => ' ',
-'_DARGS' => '/jsp/home/quickbuycontent.jsp',
-
-
- );
- while (@orderlist) {
- ($item, $qty, @orderlist) = @orderlist;
- push @submit,
- 'k1', $item,
- '_D:k1', ' ',
- 'k3', $qty,
- '_D:k3', ' ';
- }
+ my ($page_output);
+ $url= "$urlbase/jsp/op/shoppingbasket.jsp;jsessionid=$jsessionid";
get_useragent();
-print STDERR "url $url; @submit.\n";
- $request= POST $url, \@submit;
- $useragent->prepare_request($request);
-printf STDERR "request %s.\n", $request->as_string;
- $response= $useragent->request($request);
- check_response($response,$url);
+ $response= $useragent->get($url);
+ check_response($response, $url);
+ $_= $response->content;
+ if (!eval {
+ while (@orderlist) {
+ ($item, $qty, @orderlist) = @orderlist;
+ m!(
+?)(\<tr class=\"tabledata)((?:_alt)?)(\"\>
+?\<td\>
+?\<input type=\"text\" name=\"k1\" value=\")(\"[^<>]*\>
+?\<input type=\"hidden\" name=\"_D:k1\" value=\" \"\>
+?\</td\>
+?\<td\>\<input type=\"text\" name=\"k3\" value=\")1(\"[^<>]*\>
+?\<input type=\"hidden\" name=\"_D:k3\" value=\" \"\>
+?\</td\>\<td\b[^<>]*\>\ \;\</td\>
+?\</tr\>
+?)((?:\<tr class=\"tabledata(?:_alt)?\"\>
+?\<td\>
+?\<input type=\"text\" name=\"k1\" value=\"\"[^<>]*\>
+?\<input type=\"hidden\" name=\"_D:k1\" value=\" \"\>
+?\</td\>
+?\<td\>\<input type=\"text\" name=\"k3\" value=\"1\"[^<>]*\>
+?\<input type=\"hidden\" name=\"_D:k3\" value=\" \"\>
+?\</td\>\<td\b[^<>]*\>\ \;\</td\>
+?\</tr\>
+?)*\<tr\>
+?\<td [^<>]* class=\"tableheading\"\>
+?\<\!--td inset--\>
+?\<table [^<>]*\>
+?\<tr\>
+?\<td align=\"right\" class=\"tabletotal\"\>
+?Sub Total
+?)!
+ or die "no blanks\n";
+
+ my ($page_head)= $`.$1;
+ my ($entry_2alt, $entry_alt2item, $entry_item2qty, $entry_qty2)
+ = ($2,$4,$5,$6);
+ my ($this_alt)= !!length $3;
+ my ($page_tail)= $7.$';
+
+ $_= $page_head.
+ $entry_2alt. ($this_alt ? '' : '_alt').
+ $entry_alt2item. $item. $entry_item2qty. $qty. $entry_qty2.
+ ($this_alt ?
+ $entry_2alt.'_alt'.
+ $entry_alt2item. $entry_item2qty. 1 . $entry_qty2.
+ $entry_2alt.
+ $entry_alt2item. $entry_item2qty. 1 . $entry_qty2
+ : '').
+ $page_tail;
+ }
+
+ m!\</head\>! or die "no </head>\n";
+ $page_output= $`. "<base href=\"$urlbase\">\n" . $& . $';
+ 1;
+ }) {
+ die "$_ huh $@ ?" unless m/\<body [^<>]*\>/;
+ $page_output= $`.$&.
+ "<h1><strong>ERRORS FROM FARNELL-FIND:</strong></h1>\n".
+ "<p><strong>".
+ encode_entities($@).
+ "</strong>\n".
+ "<h1>In output data:</h1>\n".
+ $';
+ }
open N, ">tmp.farn.basket.html" or die $!;
- print N $response->content or die $!;
+ print N $page_output or die $!;
close N or die $!;
exec 'w3m','./tmp.farn.basket.html'; die $!;
}