Ejemplo n.º 1
0
def make_keywords_list(academy_xlsx_path, comp_academy_path, stock_title_path, NaverTrend_path, array2D_path,
                       start_date, end_date, use_navertrend, use_downloaded_navertrend):
    compressed_words = comp_text.extract_keyword(dir_path=academy_xlsx_path, return_num=5, freq_ctr=0.75)
    comp_compressed_words = comp_text.extract_keyword(dir_path=comp_academy_path, return_num=100, freq_ctr=0.0)

    stock_name_list = read_stockname(academy_xlsx_path)

    compressed_only_words = pinset(compressed_words)
    comp_only_words = pinset(comp_compressed_words)

    print("compressed only words")
    print(compressed_only_words)
    print("comp only words")
    print(comp_only_words)
    print('')

    # def Remove_words(stock_title_dir_path, stock_file_name, keywords_dir_path, comp_dir_path,  array2D_xlsx_path, array2D_xlsx_name)
    convert_to_str(compressed_only_words)
    convert_to_str(comp_only_words)

    search_words, removed_words = remove_useless_words.Remove_words(stock_title_dir_path=stock_title_path,
                                                                    stock_file_name='stock_title',
                                                                    keywords=compressed_only_words,
                                                                    comp_list=comp_only_words)
    print(" search_words : ")
    print(search_words)
    print(" removed_words : ")
    print(removed_words)
    result = []

    if use_navertrend == True:
        download_xlsx_from_NaverTrend.download_xlsx(search_words=search_words, start_date=start_date, end_date=end_date,
                                                    download_path=NaverTrend_path)

        slope_list = comp_NaverTrend.comp_NaverTrend_xls(dir_path=NaverTrend_path, array2D_xlsx_path=array2D_path)
        print("slope_list : ")
        print(slope_list)
        print(slope_list[:(int)(len(slope_list) / 2)])

        for i in range(0, len(slope_list), 1):
            result.append(slope_list[i][0])
    else:
        result = search_words

    if use_downloaded_navertrend == True:
        slope_list = comp_NaverTrend.comp_NaverTrend_xls(dir_path=NaverTrend_path, array2D_xlsx_path=array2D_path)
        print("slope_list : ")
        print(slope_list)
        print(slope_list[:(int)(len(slope_list) / 2)])
        for i in range(0, len(slope_list), 1):
            result.append(slope_list[i][0])

    return stock_name_list, result  # [[키워드1, 검색어 트래픽], [키워드2, 검색어 트래픽] ... ]으로 초기화 되어있는 리스트를 return합니다.
    def Set_comp_keywords_list(self, comp_dir_path, array2D_xlsx_path,
                               array2D_xlsx_name):
        print("Set comp_keywords_list")
        comp_dir_path = comp_dir_path + '/' + 'NaverTrend'

        self.comp_keywords_list = comp_NaverTrend.comp_NaverTrend_xls(
            dir_path=comp_dir_path,
            array2D_xlsx_path=array2D_xlsx_path,
            array2D_xlsx_name=array2D_xlsx_name)
    def Set_keywords_list(self, dir_path, array2D_xlsx_path,
                          array2D_xlsx_name):
        # comp_NaverTrend.py 의
        # def comp_NaverTrend_xls(dir_path = None, array2D_xlsx_path=None, array2D_xlsx_name='2D_array.xlsx'): 을 call하여 사용합니다.

        self.keywords_list = comp_NaverTrend.comp_NaverTrend_xls(
            dir_path=dir_path,
            array2D_xlsx_path=array2D_xlsx_path,
            array2D_xlsx_name=array2D_xlsx_name)
Ejemplo n.º 4
0
def Keywords(start_date,
             end_date,
             word_list,
             comp_word_list,
             chrome_path='c:\\data\\chromedriver.exe',
             default_path='',
             academy_xlsx_path='',
             NaverTrend_path='',
             array2D_path='',
             stock_title_path='',
             original_stock_title_path='C:/data/Keywords/Stock_title',
             update_stock_title=False):
    if default_path == '':  # 기본경로를 설정해줍니다.
        default_path = 'C:/data/' + 'Keywords/' + datetime.datetime.now(
        ).strftime('%Y-%m-%d_%H-%M-%S') + word_list[0] + '_포함_' + str(
            len(word_list)) + '_종목'

    # 경로설정하는 부분.
    academy_xlsx_path, NaverTrend_path, array2D_path, stock_title_path = path_controller(
        default_path, academy_xlsx_path, NaverTrend_path, array2D_path,
        stock_title_path)

    comp_default_path = default_path + '/' + 'Comp_data'
    comp_academy_path, comp_NaverTrend_path, comp_array2D_path, comp_stock_title_path = path_controller(
        comp_default_path)

    # 분석하려고 하는 그룹의 데이터를 받아옴
    get_keyword_from_academy_re.download_keywords(
        start_date=start_date,
        end_date=end_date,
        search_key=word_list,
        ID='academy',
        PWD='academy123',
        download_path=academy_xlsx_path,
        chrome_path=chrome_path)
    # 비교 대조군을 만들기 위한 데이터를 받아옴
    get_keyword_from_academy_re.download_keywords(
        start_date=start_date,
        end_date=end_date,
        search_key=comp_word_list,
        ID='academy',
        PWD='academy123',
        download_path=comp_academy_path,
        chrome_path=chrome_path)

    compressed_words = comp_text.extract_keyword(dir_path=academy_xlsx_path,
                                                 return_num=5,
                                                 freq_ctr=0.75)
    comp_compressed_words = comp_text.extract_keyword(
        dir_path=comp_academy_path, return_num=100, freq_ctr=0.0)

    compressed_only_words = pinset(compressed_words)
    comp_only_words = pinset(comp_compressed_words)

    print("compressed only words")
    print(compressed_only_words)
    print("comp only words")
    print(comp_only_words)
    print('')

    get_keyword_from_academy_re.dir_path_check(
        array2D_path)  #2D_array_path check and make directory
    get_keyword_from_academy_re.dir_path_check(comp_array2D_path)
    if update_stock_title:  # 기업명을 네이버에서 새로 받아오도록 하는 설정
        get_stock_title.Make_Stock_title_xlsx(
            dir_path=stock_title_path)  # 기업명을 네이버에서 모두 가져옴
    else:
        get_stock_title.Copy_Stock_title_xlsx(
            original_path=original_stock_title_path,
            copy_path=stock_title_path,
            file_name='stock_title.xlsx')

    # def Remove_words(stock_title_dir_path, stock_file_name, keywords_dir_path, comp_dir_path,  array2D_xlsx_path, array2D_xlsx_name)
    convert_to_str(compressed_only_words)
    convert_to_str(comp_only_words)

    search_words, removed_words = remove_useless_words.Remove_words(
        stock_title_dir_path=stock_title_path,
        stock_file_name='stock_title',
        keywords=compressed_only_words,
        comp_list=comp_only_words)
    print(" search_words : ")
    print(search_words)
    print(" removed_words : ")
    print(removed_words)

    download_xlsx_from_NaverTrend.download_xlsx(search_words=search_words,
                                                start_date=start_date,
                                                end_date=end_date,
                                                download_path=NaverTrend_path)

    slope_list = comp_NaverTrend.comp_NaverTrend_xls(
        dir_path=NaverTrend_path, array2D_xlsx_path=array2D_path)
    print("slope_list : ")
    print(slope_list)
    print(slope_list[:(int)(len(slope_list) / 2)])

    return slope_list  # [[키워드1, 검색어 트래픽], [키워드2, 검색어 트래픽] ... ]으로 초기화 되어있는 리스트를 return합니다.