Two scripts to automate searching for Pencil stock

Discussion in 'iPad Accessories' started by gibbz, Dec 10, 2015.

  1. gibbz macrumors 68030

    Joined:
    May 31, 2007
    #1
    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.
     

    Attached Files:

  2. ed. macrumors member

    Joined:
    Jan 31, 2008
    #2
    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?
     
  3. gibbz thread starter macrumors 68030

    Joined:
    May 31, 2007
    #3
    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.
     
  4. ed. macrumors member

    Joined:
    Jan 31, 2008
    #4
    Thanks for your help! I've managed to make it work, I think!
     
  5. ed. macrumors member

    Joined:
    Jan 31, 2008
    #5
    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!
     
  6. gibbz thread starter macrumors 68030

    Joined:
    May 31, 2007
  7. luigi408 macrumors 6502

    Joined:
    Jun 22, 2008
    #7
    Hi,

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

    Thanks!
     
  8. gibbz thread starter macrumors 68030

    Joined:
    May 31, 2007
    #8
    That's just a placeholder. You can change it to save anywhere you want.
     

Share This Page