티스토리 뷰

예시 :  네이버 뉴스 수집 자료

* 최근 1개월간의 뉴스 제목에 포함된 단어들 중에서 최근 1주일 사이에만 등장하는 단어들 목록을 출력하는 프로그램

 

def LoadItems_NaverNews():
    gs1 = cBGoogleSpread()
    spreadName = "NaverNews"
    date0 = datetime.now()
    date1 = date0 - timedelta(weeks=1) # 1 week ago
    date2 = date1 - relativedelta(months=1) # 1 month ago

    try:
        ss1 = gs1.OpenSpreadsheet(spreadName)
    except Exception as e:
        print("{???]", str(e))
        return DataFrame()
    sheetName = "Overview"
    itemList_DF = gs1.ReadSheet(ss1, sheetName)
    itemInfoList = itemList_DF.to_dict('records')
    newNounsString = "Latest Nouns compared to a last month\n\n"
    textKey = "Title"
    dateKey = "I.Date"
    for itemInfo1 in itemInfoList:
        # print(itemInfo1)
        keyWord1 = itemInfo1['Keyword']
        itemData_DF=LoadData_NaverNews(itemInfo1)
        newNouns = ExtractNewNounCount(itemData_DF, textKey, dateKey) # Dict
        if not newNouns: continue
        newNounsString += "["+keyWord1+"]\n"
        for noun1 in newNouns.keys():
            newNounsString += noun1 +", "
        newNounsString += "\n\n"

        #WordCloud01(titleString2)
    print("[NewNounsString]", newNounsString)
    print("[End] LoadItems_NaverShopping()")

    return itemData_DF

반응형
반응형
250x250
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함