[Tutor] automate add-to-cart with python

Benjamin Fishbein bfishbein79 at gmail.com
Mon Jan 28 23:51:15 CET 2013


Hello,
I'm trying to automate putting a series of items into my cart. Here's the html for the add-to-cart button on the website:
<a class="PDP_button_addToCart2" href="http://cart.half.ebay.com/ws/eBayISAPI.dll?HalfAddItemToCart&ap=additem&itemid=343343950913&pr=57017296&fromshop=1">Add to cart</a></td>
Using the cookielib and urllib2 module, I did:

a= text.find("href")+6
b = text.find('"', a)
url = text[a:b]
new_text = opener.open(url).read()

It goes to the page that shows my cart, but there are zero items--the item is not added to the cart.
I'm guessing this has something to do with:

class="PDP_button_addToCart2"

I'm not sure how to have Python click the button.
In general, despite scouring the Internet, I haven't been able to figure out how to get Python to cause javascripts I find in the html to be run.
Any help would be greatly appreciated.
Thanks,
Ben

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130128/3ce320e9/attachment.html>


More information about the Tutor mailing list