Retrieving text from a URL using PHP
| From: | Anthony Ritter | Date: | Thu, 06 Jun 2002 15:43:50 +0000 |
| Subject: | Retrieving text from a URL using PHP | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-100935@lists.php.net to get a copy of this message | ||
Is there any way to retrieve data (for example - the text *within* a table)
from another URL so that only the text appears and not the html (tables,
cells, colors, etc.)
Below is a script which opens and reads a URL and then outputs the complete
URL.
I am just looking for the text output.
Thank you in advance.
Tony Ritter
.......................................................................
<html>
<head>
<title>Retrieving text from a URL</title>
</head>
<body>
<?
$theurl="http://www.blah.com";
if (!($fp=fopen($theurl, "r")))
{
echo "Could not open the URL";
exit;
}
$contents= fread($fp, 1000000);
fclose($fp);
echo "$contents";
echo "<br>"."This information retrieved from<br>"."<a
href=\"$theurl\">$theurl</a><br>"."on ".(date("l jS F Y
g:i a T"));
?>
</body>
</html>