For this first you need to download the page and then parse that page and fetch the required text.
you can use file_get_contents(); cURL, fopen etc to download the page at the given URL.
Once downloaded you can parse it using HTML DOMDocument.
Download using this,
1.
PHP Code:
<?php
ini_set('default_socket_timeout', 10);
$url = "URL";
if( file_get_contents( urlencode($url) ) === false ) {
// failure
} else {
// success
}
?>
Or 2.
PHP Code:
<?php
$url = 'URL';
$text = content_from_curl($url);
function content_from_curl($url)
{
$content = false; // we will populate this with the downloaded content, if we get, else return false
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 2);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
if( ( $content = curl_exec($curl) ) === false ) { //failure
echo 'cURL error: ' . curl_error($ch);
}
else {
//success
}
curl_close($curl); // close the connection
return $content;
}
?>
Check this out to get some idea on
how to parse HTML.