Example #1
0
    def getArticle(self, request, queryset, *arg1, **arg2):
                for feed in queryset:
                        logger.info('start to fetch article,The title is %s', feed.title)
                        try:
                                if feed.feed.start_target != 'nohtml':

                                        logger.info('fetch new article %s,at %s' % (feed.link, datetime.now()))
                                        contenthtml = ''
                                        try:
                                                result = getpage(feed.link, 30)
                                                if result.code == 200:
                                                        if len(feed.feed.start_target) != 0 and feed.feed.start_target != 'nohtml':
                                                                contenthtml = htmllib.parsehtml(result.read(), feed.feed, feed.link, feed.feed.feedurl)
                                                        else:
                                                                contenthtml = feed.excerpt
                        
                                                        self.__store_article(contenthtml, feed)
                        
                                                else:
                                                    feed.fetch_stat = 2
                                                    feed.save()
                                        except Exception, data:
                                                logger.info('DownloadError in get %s.the error is %s', feed.link, data)
                                                return False
                                else:
                                    self.__store_article(feed.excerpt, feed)
Example #2
0
def handle_result(rpc, entry, feed_url, url, feed_target):
        try:
            result = rpc.get_result()
            if result.status_code == 200:
                contenthtml = htmllib.parsehtml(result.content, feed_url, feed_target)


                if contenthtml != None:
                    theresult.append([contenthtml])

                else:
                    print ('something is wrong at %s,the feed is %s,the target is %s ,please check,the call back result is none', url, feed_url, feed_target)
        except Exception, Error:
            logging.debug ('DownloadError in get  %s.' % url)