Tony, try searching the archives - the regular expression that's required to
get the stuff between the <body> tags has been asked many, many times
before.

Here's a quick bit of code that might get you started:

<?php

$temp_file = "/tmp/" . uniqid("yahoo");
$myfile = "/path/to/myfile.html";
$file = "http://www.yahoo.com/";;
$their_text = implode("", file($file));

# now let's get our match between the body tags.
if(!preg_match("!<body[^>]+>(.*)</body>!is", $their_text, $matches))
{
 # No matches?
} else
{
 $my_text = $matches[1];

 # Copy to temp file first....
 $fp = fopen($temp_file, "w");
 fwrite($fp, $my_text);
 fclose($fp);

 if(filesize($temp_file) > 0)
 {
  # We probably got some good text.
  copy($temp_file, $myfile);
 } else
 {
  echo "Something flakey's happened.\n";
 }
 unlink($temp_file);
}

?>

Have a look at phpbuilder.net for tutorials on this sort of thing - I seem
to remember having seen some tutorials there on this sort of thing not so
long back.

Points of reference:
http://www.php.net/file
http://www.php.net/fopen
http://www.php.net/fread
http://www.php.net/fclose
http://www.php.net/fwrite
http://www.php.net/preg_match
http://www.php.net/preg_replace


James

"Tony Crockford" <[EMAIL PROTECTED]> wrote:
> Hi
>
> What I'd like to do is open an html file, strip out the content between
> the <body></body> tags so that I can insert it into my own template.
>
> Has anyone got any good resources or tutorials I could read to help me
> accomplish this simple sounding task.
>
> I have no idea where to start! ;o)
>
> Thanks everyone.
>
> Tony
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to