37 users online (0 members and 37 guests)  


  Results 1 to 2 of 2

Related

  1. How To Promote A Website After Penguin Updation??    Forum: Search Engine Optimization - SEO - Forum
    Replies: 1
  2. perl problem    Forum: CGI Perl Forum
    Replies: 2
  3. Perl Counter Problem    Forum: CGI Perl Forum
    Replies: 4
  4. Perl dbi with mysql problem    Forum: CGI Perl Forum
    Replies: 1
  5. cgi script/perl problem    Forum: CGI Perl Forum
    Replies: 4
  1. #1
    itbug's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    2

    problem with rss updation and perl

    Hello Perl Bugs,

    Below is the code which is useful to read file <file>.xml and parse it, cached it and store it into the db. But I am getting the error into that.

    Code:
    #!/usr/bin/perl
    my $parsed_rss_instances;
    sub doExternalChannel
    {
        my ($newsversion, $cid, $url)=@_;
        my $html_cache="";
        my $nb=0;
        my $httpstatus=0;
    
        debug_msg(3, "in doExternalChannel, cid=$cid, newsversion:$newsver
    +sion\n");
      
        my $content="";
        my $url_digest = Digest::MD5::md5_hex( $url );
        print STDERR "in reading file, using $url_digest for $url\n";
        debug_msg(4, "Reading from file $channeldir/$url_digest.xml\n");
        if (open FILE, "<$channeldir/$url_digest.xml")
        {
            # we can read the file
            close FILE;
        }
        else
        {
          warn "Cannot open $channeldir/$url_digest.xml\n";
          return ("",0);
        }
        debug_msg(4, "About to parse $channeldir/$url_digest.xml\n");
        eval
        {            ### TRY
        my $rss_instance;
        if( $parsed_rss_instances->{$url_digest} )
        {
            $rss_instance = $parsed_rss_instances->{$url_digest};
        }
        else
        {  
            $rss_instance = XML::RSS->new();        
            $rss_instance->parsefile("$channeldir/$url_digest.xml");      
    +  
            $parsed_rss_instances->{$url_digest} = $rss_instance;
        }
        my $updatedb = 1;        #we put result in DB
       ($html_cache, $nb) = &cacheHTMLChannel($cid, $newsversion, $rss_ins
    +tance, $updatedb);
        };
    
        ### CATCH
        if ($@)
        {
            my ($name, $url)=DBAccess->sqlSelect ("name, url", "channel", 
    +"cid=$cid");
            warn "\n\n###WARNING: '$name' Channel file contains incorrect 
    +RSS content cid=$cid:\n\n$@\n\nThis is not an error but a warning exp
    +laining that Metadot Portal Server fetched a file that is not a corre
    +ct RSS file. If this error persists please contact the creator of thi
    +s channel file or the channel webmaster, i.e. the guy running the web
    +site at $url\n\n\n";
        }
        debug_msg(4, "doExternalChannel: end  cid=$cid\n");
        return($html_cache, $nb);
    }
    This code is a part of metadot ( the free online portal server) so in that the feeds are not updating.
    can u plz tell me wt is the problem I am new to perl so getting some problem to do some RnD witth this code snippt. for updating my feeds I have to run the file in prompt so I am getting like that
    in reading file, using ba671e66ff6cbf92e300ec9ec32ee4f7 for http://xml.newsisfree.com/feeds/39/1439.xml Cannot open channels/ba671e66ff6cbf92e300ec9ec32ee4f7.xml

    so like that I am getting all the feed name one by one......
    Plz help me or guide me......

  2. #2
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    Re: problem with rss updation and perl

    try this insted:

    (give me a link, or the complete error message)
    Code:
    #!/usr/bin/perl
    my $parsed_rss_instances;
    sub doExternalChannel
    {
        my ($newsversion, $cid, $url)=@_;
        my $html_cache="";
        my $nb=0;
        my $httpstatus=0;
    
        debug_msg(3, "in doExternalChannel, cid=$cid, newsversion:$newsver
    +sion\n");
      
        my $content="";
        my $url_digest = Digest::MD5::md5_hex( $url );
        print STDERR "in reading file, using $url_digest for $url\n";
        debug_msg(4, "Reading from file $channeldir/$url_digest.xml\n");
        if (!(-r "$channeldir/$url_digest.xml"))
        {
          warn "Cannot open $channeldir/$url_digest.xml\n";
          return ("",0);
        }
        debug_msg(4, "About to parse $channeldir/$url_digest.xml\n");
        eval
        {            ### TRY
        my $rss_instance;
        if( $parsed_rss_instances->{$url_digest} )
        {
            $rss_instance = $parsed_rss_instances->{$url_digest};
        }
        else
        {  
            $rss_instance = XML::RSS->new();        
            $rss_instance->parsefile("$channeldir/$url_digest.xml");      
    +  
            $parsed_rss_instances->{$url_digest} = $rss_instance;
        }
        my $updatedb = 1;        #we put result in DB
       ($html_cache, $nb) = &cacheHTMLChannel($cid, $newsversion, $rss_ins
    +tance, $updatedb);
        };
    
        ### CATCH
        if ($@)
        {
            my ($name, $url)=DBAccess->sqlSelect ("name, url", "channel", 
    +"cid=$cid");
            warn "\n\n###WARNING: '$name' Channel file contains incorrect 
    +RSS content cid=$cid:\n\n$@\n\nThis is not an error but a warning exp
    +laining that Metadot Portal Server fetched a file that is not a corre
    +ct RSS file. If this error persists please contact the creator of thi
    +s channel file or the channel webmaster, i.e. the guy running the web
    +site at $url\n\n\n";
        }
        debug_msg(4, "doExternalChannel: end  cid=$cid\n");
        return($html_cache, $nb);
    }



Tags for this Thread