Graças a Deus inventaram o DOMDocument .!
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
</head>
<body>
<?php
$WebSite = 'http://forum.imasters.com.br/topic/436100-pegar-parte-de-site-e-mostrar-no-meu/';
$DOMDocument = new DOMDocument( '1.0', 'utf-8' );
$DOMDocument->preserveWhiteSpace = false;
@$DOMDocument->loadHTML( file_get_contents( $WebSite ) );
echo utf8_decode( $DOMDocument->getElementsByTagName( 'title' )->item(0)->nodeValue );
?>
</body>
</html>
Saída:
pegar parte de site, e mostrar no meu - iMasters Fóruns
Você pode procurar por XPath, para achar elementos com atributos específicos no Documento.
como por exemplo:
<?php
$WebSite = 'http://forum.imasters.com.br/topic/436100-pegar-parte-de-site-e-mostrar-no-meu/';
$DOMDocument = new DOMDocument( '1.0', 'utf-8' );
$DOMDocument->preserveWhiteSpace = false;
@$DOMDocument->loadHTML( file_get_contents( $WebSite ) );
$DOMXPath = new DOMXPath( $DOMDocument );
echo utf8_decode( $DOMXPath->query( './/meta[@name="keywords"]' )->item( 0 )->getAttribute( 'content' ) );
?>
Saída:
pegar,parte,site,mostrar,meu,Olá,todos,Pessoal,fiz,uma,boa,pesquisa,mas,ainda,consegui,nada,que,preciso,fazer