Ejemplo n.º 1
0
    def getdailynews(self):
        date=self.getformatdate()
        newslist=[]
        newsjsonlist={}
        source=['268_new.json','270_new.json']

        for index in range(2):
            self.news_url = third_party_api.newsapi%(date,source[index]);
            newslist.extend(self.getpernews())

        newslist=sorted(newslist,key=lambda newsitem:newsitem['putdate'],reverse=True)
        latestnews=basesqlutil.select_latest_news_sql()
        if(latestnews is None) :
            newsjsonlist["nextId"]='0'
            indexofsame=2
        else :
            lastnewsid=latestnews[1]
            newsjsonlist["nextId"]=lastnewsid
            indexofsame =self.getsameindex(lastnewsid,newslist)
            if((indexofsame is not -1) and (indexofsame is not 0)) :
                newslist=newslist[0:indexofsame]
        #newslist=self.save_per_articlecontent(newslist)
        newsjsonlist["newslist"]=newslist
        newsjsonlist=json.dumps(newsjsonlist).decode("unicode-escape")
        if((indexofsame is not 0) and len(newslist)>8) :
            try:
                basesqlutil.news_insert_sql('news',str(newslist[0]['articleId']),newsjsonlist,str(date))
            except:
                return "error"
        return str(newsjsonlist)
Ejemplo n.º 2
0
def get_latestnews(type):
    if (type == 'news'):
        latestnews = str(basesqlutil.select_latest_news_sql()[2])
    else:
        latestnews = basesqlutil.select_latest_blog_sql()
    return latestnews
Ejemplo n.º 3
0
def get_latestnews(type):
    if(type=='news') :
        latestnews =str(basesqlutil.select_latest_news_sql()[2])
    else :
        latestnews =basesqlutil.select_latest_blog_sql()
    return latestnews