Using perl and a shell script to check if a product from Samsung is available I wanted to see when a certain product, data cable for a samsung phone, would be ready. I did some looking at their web page (see commented out $url statement), and found that they use AJAX to update their inventory status. So I built the perl page below to check what I was interested in.
  #!/usr/bin/perl -w

  # by Michael Mayer-Oakes
  # 6/27/2009

  use strict;
  use WWW::Mechanize;
  use diagnostics;

  my ($p, $nValue, $rowsreturned, $htmlCode, $length, $return_val, 
  	$script, $url, $content, @results); 
  my $mech = WWW::Mechanize->new(onwarn => undef);

  # first checked the page that told me "out of stock"
  #my $url = 'http://http://www.samsung.com/us/consumer/accessory/type/accList.do?group=mobilephones&type=mobilephones&subtype=mobilephoneaccessories&subsubtype=datacableskits';

  # use their ajax url
  $url ='http://www.samsung.com/common/httpRequest.do';
  # got this from the page showing the "out of stock" message, check the javascript section
  #  note, multiple "product_id" can be sent as pipe delimited entries
  $content = 'url=https://mobile.samsung.com/accessories/view_acc_price.jsp&site_cd=us&product_id=PKT200BBEG/STD';
  $mech->post($url, content => $content);
  # results
  # PRODUCT_ID|MSRP|PROMO_FROM|PROMO_TO|PROMO_PRICE|PROMO_FLAG|AVAILABILITY_FLAG

  $htmlCode = $mech->content();
  @results = split(/\|/, $htmlCode);

  # if any problems or if it comes back as available then show the results
  if (!defined($results[6]) || $results[6] eq "Y") {
    print "Looks like the Samsung Data Cable is available!\n";
    # don't print first entry, has CRLFs and other stuff
    #print "length ".length($results[0])."\n";
    #print "PRODUCT_ID ".$results[0]."\n";
    print "PRODUCT_ID PKT200BBEG/STD\n";
    print "MSRP ".$results[1]."\n";
    print "PROMO_FROM ".$results[2]."\n";
    print "PROMO_TO ".$results[3]."\n";
    print "PROMO_PRICE ".$results[4]."\n";
    print "PROMO_FLAG ".$results[5]."\n";
    print "AVAILABILITY_FLAG ".$results[6]."\n";
  }

  # end of script
  
Now a simple shell script, to email the results, if anything is reported
  #!/bin/sh
  #
  #
  # by Michael Mayer-Oakes
  # June 27, 2009
  #

  # check if data cable is ready, if so email to myself
  DataCable="`/path/to/perl/samsungcablecheck.pl`"
  # protect against NULL emails
  if [ "$DataCable" != "" ]
	then
	echo "$DataCable" | mail -s "Data Cable for Sumsung Phone IN STOCK!" me@home.org
  fi
  
Lastly, our good friend cron
  5 1 * * * /path/to/script/samsungCheck
  
And get ready for an email, when the data cable is back in stock!