<?php
function getTitle( $string ) {
$s = strpos( $string, "<title>" ) + 7;
$e = strpos( $string, "</title>", $s );
$l = $e - $s;
return substr( $string, $s, $l );
}
function getSection( $string ) {
$s = strpos( $string, '<table cellspacing="0" cellpadding="0" width="100%"><tr><td class="cbt" align="left">' ) + 85;
$e = strpos( $string, "</tr></table>", $s );
$l = $e - $s;
$output = substr( $string, $s, $l );
$output = strip_tags( $output );
$output = explode( "/", $output );
$section = "";
$count = count( $output );
for ( $i = 0; $i < $count; $i++ ) {
if ( $i != ( $count - 1 ) ) {
$section .= trim( $output[$i] ) . " -> ";
}
else {
$section .= trim( $output[$i] );
}
}
return $section;
}
function getArtNo( $string ) {
$s = strpos( $string, "Код товара: <b>" ) + 15;
$e = strpos( $string, "</b>", $s );
$l = $e - $s;
return substr( $string, $s, $l );
}
function getDescription( $string ) {
$s = strpos( $string, 'method=post name="MainForm">' ) + 28;
$e = strpos( $string, "<img", $s );
$l = $e - $s;
$output = substr( $string, $s, $l );
$output = strip_tags( $output );
$output = trim( $output );
return $output;
}
function getImage( $string ) {
$s = strpos( $string, '<div style="float:right;"align="center">' ) + 40;
$s = strpos( $string, 'src="', $s ) + 5;
$e = strpos( $string, '"', $s );
$l = $e - $s;
return "http://www.softair.su/" . substr( $string, $s, $l );
}
$file = file_get_contents( "http://www.softair.su/index.php?productID=150" );
echo "Title: \r\n";
echo getTitle( $file ) . "\r\n\r\n\r\n";
echo "Section: \r\n";
echo getSection( $file ) . "\r\n\r\n\r\n";
echo "ArtNo: \r\n";
echo getArtNo( $file ) . "\r\n\r\n\r\n";
echo "Description: \r\n";
echo getDescription( $file ) . "\r\n\r\n\r\n";
echo "Image: \r\n";
echo getImage( $file );
?>