1#!/opt/local/bin/perl 2 3use strict; 4use FEAR::API -base; 5 6my %prod_id; 7my $output_file = io('output.ecost'); 8 9url('http://www.ecost.com/ecost/ecsplash/shop/detail~dpno~604639.asp'); 10 11extmethod('Regexp::GlobalBind'); 12while ( has_more_links ) { 13 fetch >> [ 14 qr(shop/detail~dpno~) => sub { 15 return if $_[0]->url =~ /detail~dpno~(\d+)~/ and $prod_id{$1}; 16 $prod_id{$1} = 1; 17 fetch($_[0]) >> [ qr(shop/detail~dpno~) => _self ]; 18 template(qr(<img src="(?#<image>http://eimages.ecost.com/prod/.+?jpg)".+?NAME="LRGMerchandiseImage".+?border="0" onError=".+?<td height="19" colspan="4" class="lbluebold">(?#<product_name>.+?)</strong></td>.+?<td colspan="" align="center" nowrap class="detailPageBargainCountdownPrice"><b>\$(?#<price>[\d,\.]+?)</b></td>)s); 19 extract; 20 postproc('$_->{product_name} =~ s([\r\n\t])()g;'); 21 invoke_handler(sub { 22 print Dump $_; 23 $output_file->println(Dump $_); 24 }); 25 }, 26 qr(shop/category~eStore.+asp) => _self, 27 ]; 28} 29 30