Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
Perl Program to click on 'Add to Cart' image and submit

New User

Oct 4, 2008, 4:34 PM

Views: 6686
Perl Program to click on 'Add to Cart' image and submit

I am trying to write a perl script that will select a product to shop from a website, enter quantity, add to cart and checkout. I have been able to select the product but i am not able to submit the 'add to cart'. The 'add to cart' is an image instead of a button. I am using POST but it is not working. Here is part of the code i am using:

my $url = "http://www.xyz.com/shop/index.php?main_page=products&cPath=2&prod_no=1;
my $browser = LWP::UserAgent->new;
resp = $browser->post($url,
['Cart_Qty' => 'form.submit()']);

Section of the HTML code:
<form name="Cart_Qty" action="http://www.xyz.com/shop/index.php?main_page=products&amp;cPath=2&amp;prod_no=1&amp;action=add_product" method="post" enctype="multipart/form-data">

<div id="cartAdd">
Add to Cart: <input type="text" name="Cart_Qty" value="1" maxlength="6" size="4" /><br /><br /><input type="hidden" name="prod_no" value="8" /><input type="image" src="includes/templates/template_default/buttons/english/button_in_cart.gif" alt="Add to Cart" title=" Add to Cart " /> </div>

Appreciate any help with this. Thanks!