Forum Moderators: coopster
<?php
$config['url'] = "http://www.sample.com"; // my domain
$config['start_tag'] = "<b>"; // start
$config['end_tag'] = "</b>"; // end
class grabber
{
var $error = '';
var $html = '';
function grabhtml( $url, $start, $end )
{
$file = file_get_contents( $url );
if( $file )
{
if( preg_match_all( "#$start(.*?)$end#s", $file, $match ) )
{
$this->html = $match;
}
else
{
$this->error = "Tags cannot be found.";
}
}
else
{
$this->error = "Site cannot be found!";
}
}
function strip( $html, $show, $start, $end )
{
if( !$show )
{
$html = str_replace( $start, "", $html );
$html = str_replace( $end, "", $html );
return $html;
}
else
{
return $html;
}
}
}
$grab = new grabber;
$grab->grabhtml( $config['url'], $config['start_tag'], $config['end_tag'] );
echo $grab->error;
foreach( $grab->html[0] as $html )
{
echo htmlspecialchars( $grab->strip( $html, $config['show_tags'], $config['start_tag'], $config['end_tag'] ) ) . "<br>";
}
?>