Skip to content

Instantly share code, notes, and snippets.

@alvinnguyen
Created April 12, 2015 23:23
Show Gist options
  • Save alvinnguyen/0aee8ee18892067eebe1 to your computer and use it in GitHub Desktop.
Save alvinnguyen/0aee8ee18892067eebe1 to your computer and use it in GitHub Desktop.
Notify stock availability for a specific size
<?php
function checkStock($url,$sku,$size, $nick = null){
$content = file_get_contents($url);
$find = $sku.'":["<span class';
$start = strpos($content,$find);
$end = strpos($content,"]]",$start);
$substr = substr($content,$start,$end-$start);
if (strpos($substr,$size) !== false){
mail("alvin@alvinnguyen.net","$nick $size Available",$url);
}
}
checkStock("http://www.eastbay.com/product/model:214312/sku:42198001/nike-free-5.0-2014-mens/black/grey/","42198001","08.0","Nike Free Men");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment