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);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.