#!/usr/bin/perl $time1=time; $oqsl=$oqs{'Boomerang'}; # Whole string # $ttok1="class=\"titlarge"; $ttok1="table width=\"100\%\" cellpadding=\"0\""; $ttok2="
";
$ttok71="br>(";
$ttok8=" руб.";
# Item Reference
$ttok9="A href=\"b";
$ttok10="\" class=\"titlarge";
# $ttok14="\" TITLE";
# Item delivery conditions
$ttok11="";
$ttok12="";
# Item picture
$ttok15=">(Оригинальная поисковая страница магазина)
\n");
undef @output;
# &IOsocket;
$resultio=IOsocket();
$inside=0;
$readytoprocess=0;
$pstring="";
$olen=$#output +1;
plog("Boomerang answer has - $olen lines");
if($olen) {
foreach $outline (@output) {
if ($outline =~ /$ttok1/) { $inside=1;};
if ($inside == 1) {
$pstring.=$outline;
$pstring=~ s/\n//g;
$pstring=~ s/\r//g;
# print ("\n");
};
if (($inside == 1) && ($outline =~ /$ttok2/)) {
$inside=0;
$readytoprocess=1;
#print "\n\n\n";
};
if ($readytoprocess == 1) {
# $pstring.="\n";
# $pstring=~ s/ NEW!<\/B><\/I>//g;
# $pstring=~ s///;
# $pstring=~ s/<\/B>//;
$ltk=$ttok3;
$rtk=$ttok4;
$p1=index($pstring,$ltk)+length($ltk);
$p2=index($pstring,$rtk)-$p1;
$itemname=substr($pstring,$p1,$p2);
##plog("Item Name=$itemname");
$ltk=$ttok5;
$rtk=$ttok6;
$p1=index($pstring,$ltk)+length($ltk);
$p2=index($pstring,$rtk)-$p1;
$itemauthor=substr $pstring,$p1,$p2;
# $ltk=$ttok51;
# $p1=index($itemauthor,$ltk)+length($ltk);
# $itemauthor=substr $itemauthor,$p1,255;
$itemauthor =~ s/<([^>]|\n)*>//g;
#plog("Item Author=$itemauthor");
$ltk=$ttok7;
$rtk=$ttok8;
$p1=index($pstring,$ltk)+length($ltk);
$p2=index($pstring,$rtk)-$p1;
$itemprice=substr $pstring,$p1,$p2;
if(length($itemprice) > 7) {
$ltk=$ttok71;
$rtk=$ttok8;
$p1=index($pstring,$ltk)+length($ltk);
$p2=index($pstring,$rtk)-$p1;
$itemprice=substr $pstring,$p1,$p2;
};
$itemprice=~ s/,/./;
$itemprice.=".00";
##plog("Item Price=$itemprice");
$ltk=$ttok9;
$rtk=$ttok10;
$p1=index($pstring,$ltk)+length($ltk);
$p2=index($pstring,$rtk)-$p1;
$itemref=substr $pstring,$p1,$p2;
# if($itemref=~ /TITLE/go) {
# $rtk=$ttok14;
# $p2=index($pstring,$rtk)-$p1;
# $itemref=substr $pstring,$p1,$p2;
# };
#print "\n";
# $ltk=$ttok11;
# $rtk=$ttok12;
# $p1=index($pstring,$ltk)+length($ltk);
# $p2=index($pstring,$rtk)-$p1;
# $itemdelivery=substr $pstring,$p1,$p2;
$itemdelivery="В результатах поиска не указана. Смотри описание товара.";
#print "\n";
$tkf=0;
$ltk=$ttok15;
$rtk=$ttok16;
if((index($pstring,$ltk) < 0) || (index($pstring,$rtk) < 0)) {
$tkf=1;
};
$p1=index($pstring,$ltk)+length($ltk);
$p2=index($pstring,$rtk)-$p1;
if($tkf) {
$itempic="/images/blank_cover.gif";
} else {
$itempic="http://www.boomerang.ru/images/book/".substr $pstring,$p1,$p2;
$itempic.="l.jpg";
};
if ($pstring =~ /$ttok13/) {
$itemname="";
$itemauthor="";
$itemprice="";
$itemref="";
$itemdelivery="";
};
$badtok1=">";
$badtok2="<";
if(($itemname =~ /$badtok1/) || ($itemname =~ /$badtok2/)) {
push(@showline,"***! Обработка страницы прервана. Неопознанный формат. ***\n");
print "\n";
last;
};
if(($itemauthor =~ /$badtok1/) || ($itemauthor =~ /$badtok2/)) {
push(@showline,"***! Обработка страницы прервана. Неопознанный формат. ***\n");
print "\n";
last;
};
if(($itemprice =~ /$badtok1/) || ($itemprice =~ /$badtok2/)) {
push(@showline,"***! Обработка страницы прервана. Неопознанный формат. ***\n");
print "\n";
last;
};
if(($itemref =~ /$badtok1/) || ($itemref =~ /$badtok2/)) {
push(@showline,"***! Обработка страницы прервана. Неопознанный формат. ***\n");
print "\n";
last;
};
if(($itemdelivery =~ /$badtok1/) || ($itemdelivery =~ /$badtok2/)) {
push(@showline,"***! Обработка страницы прервана. Неопознанный формат. ***\n");
print "\n";
last;
};
if(($itempic =~ /$badtok1/) || ($itempic =~ /$badtok2/)) {
$itempic="/images/blank_cover.gif";
};
$lists++;
if ($itemname ne "") {
if (index($itemprice,".") < 0) { $itemprice=$itemprice.".";};
if (index($itemprice,".") == 1) { $itemprice=" ".$itemprice;};
if (index($itemprice,".") == 2) { $itemprice=" ".$itemprice;};
if (index($itemprice,".") == 3) { $itemprice=" ".$itemprice;};
if (index($itemprice,".") == 4) { $itemprice=" ".$itemprice;};
if (index($itemprice,".") == 5) { $itemprice=" ".$itemprice;};
if (index($itemprice,".") == 6) { $itemprice=" ".$itemprice;};
push(@showline2,"$itemprice ||$itemname||$itemauthor||http://www.boomerang.ru/book/b$itemref||$itemdelivery||$shop||$oqsl||$itempic\n");
};
$pstring="";
$readytoprocess=0;
};
};
};
print "";
$time2=time;
1;