1#!/opt/local/bin/perl
2
3use strict;
4use FEAR::API -base;
5
6my $output_file = io('output.mastermindtoys');
7
8url('http://www.mastermindtoys.com/');
9
10extmethod('Regexp::GlobalBind');
11
12while ( has_more_links ) {
13    fetch >> [
14	      qr(product\.asp\?product_code) => sub {
15		  fetch($_[0]) >> [ qr(product_code) => _self ];
16 		  template(qr(<img src="(?#<image>/store[^>]+?gif)" alt="(?#<product_name>.+?)" height="250" width="250" border="0">.+?<span style="color:#990000;font-size:20px;"><b>\$(?#<price>[\d\.,]+)</b>&nbsp;)so);
17		  extract;
18		  absolutize_url('image');
19		  invoke_handler(sub {
20				     print Dump $_;
21				     $output_file->println(Dump $_);
22				 });
23	      },
24	      qr(category\.asp\?cat=\d+) => _self,
25	     ];
26}
27
28