Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

gibbz

macrumors 68030
Original poster
May 31, 2007
2,701
100
Norman, OK
Hi all,

After spending days manually searching for Pencil stock, I wrote two simple scripts to query Best Buy and Apple for stock. They worked as advertised, alerting me this morning that Best Buy had stock online. For myself, I set up a cron job to execute the scripts every 5 minutes and things seemed to work.

Best Buy
- https://gist.github.com/jeremygibbs/1a6c248d12dda568d67d
- You will need an API key from: https://developer.bestbuy.com
- This searches for both online and in-store availability
- For in-store, you give a lat/lon and a search distance
- If either is available, an email alert is sent with a link to the product

Apple
- https://gist.github.com/jeremygibbs/1d62544ee57dc4ee8633
- This searches for in-store availability
- You give a zip code.
- I haven't found the correct api call for distance, but you could easily filter
- If available, an email alert is sent with a link to the product

For both scripts, an html file is written for stand-alone viewing of availability status, or within Panic's Status Board app. I've attached a sample image to show what Status Board looks like.

As a caveat, I am not a php programmer - just familiar enough with the language to be functional. I understand that these could be written better, but my goal was to get something that worked.

Hopefully this will be a helpful starting point for those struggling to find stock.
 

Attachments

  • IMG_0002.jpg
    IMG_0002.jpg
    88.5 KB · Views: 240
Hey, I really appreciate your sharing this! I have a couple of questions, though: first how do I use this : )) and second is there a way to adapt this to work on european (namely German) apple stores?
 
Hey, I really appreciate your sharing this! I have a couple of questions, though: first how do I use this : )) and second is there a way to adapt this to work on european (namely German) apple stores?

I set these up on my server and made a cron job to execute them every 5 minutes. You can use them locally on your machine, either by command line (/path/to/php scriptname.php) or by opening in a browser.

For German Apple Stores, replace all occurrence in the script of 'MK0C2AM/A' with 'MK0C2ZM/A'. This is the country specific part number for the Pencil. The url to call changes to "http://store.apple.com/de/retail/availabilitySearch?parts.0=MK0C2ZM/A&zip=10117" (where zip is just your local postal code). Also be sure and replace all occurrences of "<SOME TEXT>" with the actual values or text you need.
 
Hey I just wanted to thank you so much for your script! Today I've been able to get the Pencil thanks to it, and in a rather unexpected way: I've checked this morning on the website and nothing was available in my area, so I kind of gave it up for the day, knowing that the stock gets into the system in the morning usually, but then a t 4pm I've got the email saying my local store had it in stock! When I got there to pick it up the guy told me they've got 20 pencils or so this morning but someone forgot to check them in the system, so they were on display but they could not sell them to walk in customers. Luckily I've been alerted only when they became properly for sale online. Thanks again!
 
  • Like
Reactions: gibbz
Hi,

Where is this located in my Mac? /PATH/TO/YOUR/WEBFILES/status_bestbuy.html

Thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.