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

                    logging.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)

                            return True
                        return False
                    except Exception, data:
                        logging.info('DownloadError in get %s.the error is %s',
                                     feed.link, data)
                        return False
                else:
                    self.__store_article(feed.excerpt, feed)
Ejemplo n.º 2
0
    def getArticle(self, request, queryset, *arg1, **arg2):
                for feed in queryset:
                        logging.info('start to fetch article,The title is %s', feed.title)
                        try:
                                if feed.feed.start_target != 'nohtml':

                                        logging.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)
                        
                                                        return True
                                                return False
                                        except Exception, data:
                                                logging.info('DownloadError in get %s.the error is %s', feed.link, data)
                                                return False
                                else:
                                    self.__store_article(feed.excerpt, feed)
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)