Amazon Random Shopper

by Darius Kazemi on November 10, 2012

in project,projects

I built a bot that randomly buys me crap on Amazon and mails it to me. Full description here.


Rodrigo Franco November 11, 2012 at 6:23 pm

Amazing idea. Would love to see the source code. I want to make one that orders me a book per month.

Bradley Momberger November 13, 2012 at 10:52 am

This is all going to work swimmingly great until a live bobcat shows up at your door.

Adrian Forest November 14, 2012 at 5:28 am

Obligatory “so this is the Amazon version of that eBay thing from XKCD strip?” comment. :)

Darius Kazemi November 14, 2012 at 9:33 am


Andy November 14, 2012 at 8:48 am

I’m having real issues with getting the login to work. Are you using CasperJS too or just PhantomJS. I try to do the click and just get an error saying it couldn’t find the selector – which is clearly there.

Are you going to share the code?

Darius Kazemi November 14, 2012 at 9:39 am

Here’s my login code:

(I’m wary about sharing all of my code because I think it violates Amazon’s ToS.)

Andy November 14, 2012 at 10:21 am

Thanks for that. I see you’re injecting jquery which might solve the problem.

Not sure why amazon would object to you buying random stuff, even if it’s automated – it’s all money in their pocket :D

If you do decide to share at some point I’d be very interested. Seems like a nice little project and could make for some weird and obscure Christmas presents for my family :)

Andy November 14, 2012 at 10:44 am

Actually, I’m getting a similar issue with your code..

TypeError: ‘undefined’ is not a function (evaluating ‘$(‘#ap_email’)')

which is basically what I got, even though the id is there in the source. :/

Darius Kazemi November 14, 2012 at 10:52 am

That error happens when jQuery isn’t injected. Make sure you’re actually injecting it — it’s possible that the path in


is incorrect based on your environment. Another thing you could do is make the injection its own step.

Darius Kazemi November 14, 2012 at 9:41 am

Oh, and I’m using Phantom alone, not Casper.

Carlo 'kj' November 21, 2012 at 5:20 pm

You are a genius! ^_^

Really, this is an amazing great idea, I really want to try to write a bot like that! (downloading phantomjs this very moment) :-)

Melissa November 14, 2012 at 3:24 pm

Would it be possible to point the bot to a specific Amazon wishlist instead?

Darius Kazemi November 14, 2012 at 3:58 pm

Sure, it’s technically feasible. As I mentioned to someone on Twitter, though — I’m mostly interested in having the most alien personal shopper imaginable, like you taught a Martian how to use Amazon and they just don’t understand humans so they click the “buy” button a bunch and there you go.

Marcos Marado November 28, 2012 at 11:15 am

Well, an interesting fork of this project of yours (and yes, I understand it would be fit for a different purpose) would be something that would do exactly the same for the first interaction, but then explore amazon generated recomendations. Meaning: after you get the first package, you rate each item, and see how amazon responds to your ratings in suggesting something else. I guess that in a few interactions Amazon would be pretty good at recommending you “random stuff” that you still like :-)

Anyway, please keep us updated with the results of each interaction: I am curious on what will shipment #2 bring! :-)

Darius Kazemi November 28, 2012 at 11:35 am

That would in fact be interesting!

I do plan to blog about not just the shipments, but also the evolution of the kind of consumer Amazon thinks Random Shopper is.

Mattias H November 19, 2012 at 7:09 pm

This is a great application that I just would love to get a copy of. Hope you share it someday so us non coders can have a go with it (Unsupported ofc and at own risk)

Braunson November 19, 2012 at 9:15 pm


Sounds like a fun app, I love to get packages, and with the cover of mystery, it makes things even better. If not public, would you consider supplying the code privately?

Liz November 20, 2012 at 11:59 am

Love that it sent you Noam Chomsky — do you know what word it used to shop and if you do, would you post it with your package unbox?


Darius Kazemi November 20, 2012 at 1:27 pm

I don’t know exactly which word (I try to keep it secret from myself to retain the mystery), but it’s pretty clear that in this case it must have been “Cartesian” and “Impulsion”.

Julia November 21, 2012 at 4:38 pm

You are adorable and this is delightful. Happy Thanksgiving!

chinob November 21, 2012 at 11:22 pm

That’s so genius. I really wanna learn about coding.. I just don’t know where to begin. recommendations perhaps?

Jonathan Barronville January 3, 2013 at 8:26 pm

Do you want to learn Computer Science or just programming?

Mariuca November 23, 2012 at 7:18 am

Hey, I saw the mysterious packages in your tumblr. Very very interesting, maybe too much randomness haha but it’s a great app! Are you considering to do it with things you would actually like? I read on your tumblr that this was your first idea, and I think it would be very insteresting too.

Tu Hoang November 24, 2012 at 2:31 am

Hi Darius,

Inspired by your project, I took a look at javascript and phantomjs. I bumped into the same post on stackoverflow and had some pieces of codes working before I found your gist today. Using essentially the same piece of code in your gist on phantomjs 1.7.0, step 1 shows load started and load completed. However, the page was empty: page.content shows empty . Subsequent console.log(document.title) is empty as well. I am wondering whether the error is only happening on 1.7.0 and that you are using an older version that actually works. Would you be able to confirm what version you are using?

Thank you :)

Darius Kazemi November 27, 2012 at 3:31 pm

I’m using 1.7. Not sure what the problem is there.

Darius Kazemi November 27, 2012 at 3:31 pm

Do make sure you set your useragent. It’s very important.

Tu Hoang November 27, 2012 at 10:20 pm

Hmm. I am not sure. I will dig into that a bit more tonight if I have time. I am unable to load a different url into page using That behavior persists with both pre-compiled binary as well as binary compiled from source. What distro are you using? I am using Archlinux.

Regarding the useragent, I believe it’s implicitly set. However, even when useragent being explicitly defined, it still doesn’t work.

Tu Hoang November 27, 2012 at 10:31 pm

Okay, confirmed. It’s platform-specific error. I am able to run my code and your code just fine on Windows 8 x64. Interestingly enough, on Windows, using page.render(‘target.png’), I don’t see any rendered snapshot on the filesystem. I need to file a bug then. Very odd …

Fredrik Säfsten November 25, 2012 at 7:09 am

I really like your idea!
I can see some improvements.
How about upping the ante and letting it spend hundreds of dollars worth of crap? Wouldn’t it feel more like childrens christmas if the stuff recieved is expensive?
Also, make sure the account has enough cash and then implement more randomization to when it places orders. This way, you can’t predict when the next thing will come either nor how often.

I’m interested to expand on your concept to build a bot that does my christmas shopping for me by analyzing my friends possible cravings and shop it for them.
Your shopping code combined with some project that analyzes peoples facebook profiles etc. would do the trick.
Granted, it may not buy the best gifts but probably the most memorable ones.

Keep up the good work!

Jon November 27, 2012 at 4:13 pm

I too would be interested in this code if you can provide it privately.

This is just the type of project that looks like it would be fun to modify and play with. :)

Rasto November 28, 2012 at 5:57 am

I had a similar business idea, see
But I haven’t had enough time to set this service up. If you were interested, we could talk about that.

Darius Kazemi November 28, 2012 at 9:35 am

I’m unable to work on stuff like this (full time job, no time anyway), but I encourage you to build this! I think it’s a cool idea.

kai December 7, 2012 at 5:46 pm

thanks for that project. Thanks to you I discovered Akos Rozmann and bought his album “12 stationer VI”…!

I am endlessly fascinated by Don Buchla’s “Source of Uncertainty” (a module for a synthesizer). You might enjoy that too. (

Victor December 11, 2012 at 8:46 pm

Love the idea and excited to see what the bot gets you next!

Comments on this entry are closed.

Previous post:

Next post: