Re: getting HTML header from URL [solved]
| From: | Jule Slootbeek | Date: | Sat, 02 Nov 2002 01:43:03 +0000 |
| Subject: | Re: getting HTML header from URL [solved] | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-122487@lists.php.net to get a copy of this message | ||
oops didn't catch two little bugs
Jule
function getTitle($url)
{
$file = @fopen($url, 'r');
if(!$file) {
$rline = "Error, contact webmaster";
} else {
while (!feof ($file)) {
$line = fgets($file);
if (substr_count(strtoupper("$line"), "<TITLE>") >= 1) {
$rline = strip_tags("$line");
//return $rline;
//fclose($file);
break;
}
}
return $rline;
}
fclose($file);
}
On Friday, Nov 1, 2002, at 20:35 US/Eastern, Jule Slootbeek wrote:
hmm, figured it out...all of a sudden it did work: here's the code, it loads a URL and returns the title... dunno what it would be used for, but it aught we some more about php.. i'll probbly implement it on a link page ir something Jule function getTitle($url) { $file = @fopen($url, 'r'); if(!$file) { $rline = "Error, contact webmaster"; } else { while (!feof ($file)) { $line = fgets($file); if (substr_count(strtoupper("$line"), "<TITLE>") >= 1) { $rline = strip_tags("$line"); return $rline; fclose($file); break; }jslootbeek@clarku.edu}fclose($file); } On Friday, Nov 1, 2002, at 20:26 US/Eastern, Jule Slootbeek wrote:well, i got it to read a html file, but the problem is that it reads it after it loads it, so it doesn't read the tags, and i'm looking for the string in between <title> and </title> is there a way using fopen() or something similar to read an html/php file before it's loaded? Jule On Friday, Nov 1, 2002, at 17:45 US/Eastern, Jule Slootbeek wrote:Jule Slootbeek jslootbeek@clarku.edu -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Jule Slootbeeki thought fopen() was only for local files, didn't even bother looking, but now i think about it..it makes perfect sence to open url's as well, thanks a lot! Jule On Friday, Nov 1, 2002, at 17:42 US/Eastern, John Nichel wrote:Jule Slootbeek jslootbeek@clarku.edu -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpDocs -> Function Reference -> Filesystem Functions -> fopen() It was hidden. Jule Slootbeek wrote:Jule Slootbeek jslootbeek@clarku.edu -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phphey is there a way to get the URL header? the <title> <meta> tags etc? i couldn't find any function in the docs, but maybe i just don't know where to look. if there's a function that pulls in an entire page that;s fine too i can work with that.. any help appreciated TIA Jule Jule Slootbeek jslootbeek@clarku.edu