#!/usr/bin/perl
$time1=time;
$oqsl=$oqs{'24x7'};
# Whole string
$ttok1='
';
# Item Name
$ttok3='H1 CLASS=title>';
$ttok4='';
# Item Author
$ttok5="P CLASS=sela>";
$ttok6=" | ";
# Item Price
$ttok7="LASS=red>";
$ttok8="\ \;руб";
# Item Reference
$ttok9="HREF=\"";
$ttok10="\">";
$ttok12="
\n");
$olen=$#output +1;
plog("24x7 answer has - $olen lines");
if($olen) {
foreach $outline (@output) {
$outline=~ s/\n//;
$outline=~ s/\r//;
# print ("\n");
if ($outline =~ /$ttok1/) {
$inside=1;
# print ("\n");
};
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);
# print "\n";
$ltk=$ttok5;
$rtk=$ttok6;
$p1=index($pstring,$ltk)+length($ltk);
$p2=index($pstring,$rtk)-$p1;
$itemauthor=substr $pstring,$p1,$p2;
$itemauthor=~ s/
/ /;
# print "\n";
$ltk=$ttok7;
$rtk=$ttok8;
$p1=index($pstring,$ltk)+length($ltk);
$p2=index($pstring,$rtk)-$p1;
$itemprice=substr $pstring,$p1,$p2;
# print "\n";
$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;
# print "\n";
if ($itemdelivery =~ /$ttok13/) {
($itemdelivery)=split (/$ttok13/, $itemdelivery);
};
$tkf=0;
$ltk=$ttok15;
$rtk=$ttok16;
if((index($pstring,$ltk) < 0) || (index($pstring,$rtk)< 0)) {
$ltk=$ttok151;
$rtk=$ttok161;
$tkf=1;
};
$p1=index($pstring,$ltk)+length($ltk);
$p2=index($pstring,$rtk)-$p1;
if($tkf) {
$itempic="http://www.24x7.ru".substr $pstring,$p1,$p2;
} else {
$itempic="http://www.24x7.ru/images/picture.jsp?fid=".substr $pstring,$p1,$p2;
};
$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;};
$strtop="$itemprice ||$itemname||$itemauthor||http://www.24x7.ru$itemref\&banner_id=metasearch||$itemdelivery||$shop||".$oqsl."\&banner_id=metasearchmain||$itempic\n";
push(@showline2,$strtop);
};
$pstring="";
$readytoprocess=0;
};
};
};
print "";
$time2=time;
1;