note 47947 added to function.file-get-contents
| From: | chphilli at NOSPAM dot gmail dot com | Date: | Mon, 06 Dec 2004 19:51:42 +0000 |
| Subject: | note 47947 added to function.file-get-contents | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-81455@lists.php.net to get a copy of this message | ||
I am working on a simple script to poll a set of rss feeds to create a list of most recently updated
websites. The idea is simple, and works well, but is extremely slow. Can anyone think of a way to
speed up the process? The slowdown really seems to be in using file_get_contents to get the rss-feed
itself.
<?php
//get the rss feed for each site, and parse out the date of the first
//(most recent) entry (marked by <item>).
//then change the date into a unix epoch time (seconds since 1/1/1970)
for($i = 0; $i < $count; $i++) {
//the next line is necessary if you are using a file for input
//$sites[$i] = rtrim($sites[$i]);
$rss_feed = file_get_contents("$rss_pre" . $sites[$i]);
$rss_feed = strstr($rss_feed, "<item>");
$date_str = remover($rss_feed, "<title>", "</title>");
sscanf($date_str, "%d/%d/%d %d:%d:%d: %s", $m, $d, $y, $h, $n, $s, $c);
if($c = "PM") {
$h = $h + 12;
}
$dates[$i] = mktime($h, $n, $s, $m, $d, $y);
}
----
Manual Page -- http://www.php.net/manual/en/function.file-get-contents.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+47947
Delete -- http://master.php.net/manage/user-notes.php?action=delete+47947&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47947&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47947&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47947&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47947&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47947&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+47947&report=yes
Search -- http://master.php.net/manage/user-notes.php