Jump to content

rss feed parsing: script silently stops working


mauricioarango

Recommended Posts

Hi,

I have a script that downloads rss news feeds, and then classifies and stores them based on a given criteria. Everything works well on my local machine, but on the final server the script just stops working half way through.

 

It doesn't give any error messages or anything that can help pin point the problem.

 

if anyone has any idea I would greatly appreciate it.

 

 

// at the beginning of my code:
error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);

set_time_limit(1800);

// this section downloads each of the rss feeds
for($ii = 1; $ii <= $rss_parser->newspapercount; $ii++)
{	
$xml_parser = xml_parser_create('UTF-8');
xml_set_object($xml_parser,&$rss_parser);
$rss_parser->setURL($ii);  // url of rss feed
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");

       echo "<br>Trying to connect to $rss_parser->server ... ";

// gets the full rss feed 
if ($f = @fopen($rss_parser->url, 'r')) 
{
            $rss_content = '';
            while (!feof($f)) {
                $rss_content .= fgets($f, 4096);
            }
            fclose($f);
       
        // once rss is downloaded processes the feed

xml_parse($xml_parser, $rss_content, true) 
                      or sprintf("XML error: %s at line %d",  
                          xml_error_string(xml_get_error_code($xml_parser)),   
                          xml_get_current_line_number($xml_parser)); 
}
xml_parser_free($xml_parser);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.