PHP Woot Checker – Tech, Wine, and Shirt Woot
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:
- Every day, Woot sells one product.
- Once the item is sold out, no more items are available for purchase.
- You don't know how many of the item is available and you may only buy three at a time.
- The shipping, regardless of product price and quantity, is $5.00.
- 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.
- 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.
- 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.
//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
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:
Save 20% with discount code
One event that's always been lacking within the document is a signal for when the user is looking at a given tab, or another tab. When does the user switch off our site to look at something else? When do they come back?...
CSS filter support recently landed within WebKit nightlies. CSS filters provide a method for modifying the rendering of a basic DOM element, image, or video. CSS filters allow for blurring, warping, and modifying the color intensity of elements. Let's have...
O'Reilly puts on the best web industry conferences in the world. These conferences include Fluent Conference, Velocity Conference, and the upcoming OSCON in Portland, Oregon from July 20-24. Open Source Convention (OSCON) is a conference that focuses specifically on open source developers and the tools and possibilities...
A while back I shared my favorite Google Chrome extension: Google Art Project. I've enjoyed seeing beautiful art when I open a new tab -- it's brought genuine happiness to my day, however small that happiness may be. About a week ago, however, the art presented had...
We have selected what we believe are the very best multipurpose WordPress themes on the market today. Our list contains a number of best sellers, several newcomers that are proving to be highly popular, and a few themes that are ideal for creating the types of...
Static site generators seem to have been becoming more and more popular recently, but they’re not one of those ephemeral novelty things that grow in popularity as quickly as they fall into oblivion shortly after. For over a decade, many different projects — 394 of...
Today it's all about testing. In 2015, many developers knows about TDD and I personally think that testing is one of the key for quality products. But what about testing in a Front-end environment? How do you guys write your tests for a responsive page or...