halley has asked for the wisdom of the Perl Monks concerning the following question:

If I get this working, this will transform into a "Cool Uses for Perl" but right now, something I'm not seeing is gumming up the works...

I'm a CafePress shop owner (shameless plug: http://www.cafepress.com/halley_designs), and I have a backlog of new graphics I want to upload to CafePress. Great, WWW::Mechanize should just do the trick, right? Well, there are some issues.

First, the cafepress "shop owners" interface is covered with javascript special handling and multi-stage input. The forms include a few hidden fields that the javascript will compute during the browser session. I can get the image uploaded, but the followup form is to provide a name, keyword tags, and a category choice. After submitting this second screen, everything says it's successful, but the name and tags and category data are not actually committed to their database.

This has been a good chance to try out WWW::Mechanize::Shell, and now I'm going to try HTTP::Recorder (which seems to have a heck of a lot of dependencies I wasn't expecting). Is there a simpler HTTP snooping proxy I should check out, just to see what is in the HTTP requests from my usual browser?

If nobody else already has any code along this path (and I've done all the Googling I can think of), then I'll continue to take this reverse-engineering approach myself. (Even if it takes more effort than just manually updating the images one at a time!)

As of this writing, the CafePress folks are still trying to build a general HTTP "API" for authenticated direct access to these sorts of data elements, but they admit they're really just a team-of-one, and the system is intended for web-to-web customization (where users of *my* website can submit custom designs to *cafepress* on the fly, and then facilitate an order of that custom product indirectly), not the plain home-to-web bulk uploads. I'll be happy to target that API when it's available but in the meantime, anyone else try this approach?

--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re: CafePress batch image uploading?
by Corion (Patriarch) on Jun 19, 2007 at 16:01 UTC

    Whenever I'm automating a website, I use the Live HTTP Headers feature of FireFox to see what requests actually fly back and forth between the website and my computer. Another tool I use is Sniffer::HTTP, but that's more for actually saving the data flying back and forth.

      Since I didn't want to rely on a particular browser, I found and chose an existing standalone proxy application to investigate the queries. (Charles). All the mentions of standalone java-based proxy files seemed to have bad links yesterday. I appreciated the suggestion of a browser plugin, though!

      One annoyance I found is that since I was developing OSX, the only browser which allowed its own proxy configuration was FireFox. (So maybe the Live HTTP Headers feature probably would have been useful after all!) Safari and Camino only go through the systemwide network proxy, so halfway through my debugging session, I was having to wade through extra proxy traffic generated by a few Dashboard widgets and such.

      I got through my initial problem, though. Now to decide how to deal with the more complex portions of their shopowner site, where there's even more multi-page sequences and I have to carry item identifiers throughout the interface.

      --
      [ e d @ h a l l e y . c c ]