PHP Woot Checker – Tech, Wine, and Shirt Woot

By  on  

If you haven't heard of Woot.com, you've been living under a rock. For those who have been under the proverbial rock, here's the plot:

  1. Every day, Woot sells one product.
  2. Once the item is sold out, no more items are available for purchase.
  3. You don't know how many of the item is available and you may only buy three at a time.
  4. The shipping, regardless of product price and quantity, is $5.00.
  5. Every once in a while (usually once a month), Woot has a "Woot-off", where they sell item after item until everything is sold out.
  6. Even more rare is the "Bag o' Crap." What are you buying? A bag of crap, but that "BOC" could be a laptop bag strap or a big screen TV. Good luck getting through the checkout process though -- BOC's usually take down the server.
  7. Woot branched out from simply tech products (woot.com) to wine and t-shirts.

Needless to say, Woot is an interesting website. I've created a PHP script that returns the product's name, price, and image.

The Code

//get the page content
$woot_content = file_get_contents('http://shirt.woot.com');

//parse for product name
$name = get_match('/<h3[^>]*>(.*)</h3>/is',$woot_content);

//parse for product price
$price = get_match('/<div class="price"><span id="PriceSpan">(.*)<dl class="saleSpecs">/is',$woot_content);

//parse for product image
$image = get_match('/<div class="saleContainer">(.*?)/>/is',$woot_content).' />';

//parse for product sold out?
$sold_out = substr_count(strtolower($woot_content),'sold out!') ? 'Sold Out!' : 'Product Left!';

$content.= '<h1>Product Name</h1>'.$name.'<br /><br />';
$content.= '<h1>Product Price</h1>'.$price.'<br /><br />';
$content.= '<h1>Product Image</h1>'.$image.'<br /><br />';
$content.= '<h1>Product Sold Out?</h1>'.$sold_out.'<br /><br />';

//gets the match content
function get_match($regex,$content)
{
	preg_match($regex,$content,$matches);
	return $matches[1];
}

A few notes about the code:

  • You can get the content using the file_get_contents() function or my URL Download Content function. Your preference will depend on your server's security settings.
  • You may use the following URL's, depending on the content/product you want:
    • http://woot.com
    • http://shirt.woot.com
    • http://wine.woot.com

Recent Features

  • By
    39 Shirts &#8211; Leaving Mozilla

    In 2001 I had just graduated from a small town high school and headed off to a small town college. I found myself in the quaint computer lab where the substandard computers featured two browsers: Internet Explorer and Mozilla. It was this lab where I fell...

  • By
    Chris Coyier&#8217;s Favorite CodePen Demos

    David asked me if I'd be up for a guest post picking out some of my favorite Pens from CodePen. A daunting task! There are so many! I managed to pick a few though that have blown me away over the past few months. If you...

Incredible Demos

  • By
    Duplicate the jQuery Homepage Tooltips

    The jQuery homepage has a pretty suave tooltip-like effect as seen below: The amount of jQuery required to duplicate this effect is next to nothing;  in fact, there's more CSS than there is jQuery code!  Let's explore how we can duplicate jQuery's tooltip effect. The HTML The overall...

  • By
    The Simple Intro to SVG Animation

    This article serves as a first step toward mastering SVG element animation. Included within are links to key resources for diving deeper, so bookmark this page and refer back to it throughout your journey toward SVG mastery. An SVG element is a special type of DOM element...

Discussion

  1. That is cool…

    Now you need to have the script send a txt message to my phone every night at midnight CST.

  2. @Mark: Shouldn’t you be at the computer already? Hah. There’s also a Firefox plugin that tells you the day’s woot:

    https://addons.mozilla.org/en-US/firefox/addon/4458

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!