import collect import analyze import visulize if __name__ == '__main__': items = [ { 'pagename': 'jtbcnews', 'since': '2017-01-01', 'until': '2017-12-31' }, { 'pagename': 'chosun', 'since': '2017-01-01', 'until': '2017-12-31' }, ] # 데이터 수집(collection) for item in items: collect.crawling(**item) # 데이터 분석 (analyze) # 데이터 시각화 (viualize)
items = [{ 'pagename': 'jtbcnews', 'since': '2017-01-01', 'until': '2017-12-31' }, { 'pagename': 'chosun', 'since': '2017-01-01', 'until': '2017-12-31' }] # 데이터 수집(collection) for item in items: endTime = time.time() - startTime print('Running crawler : ' + str(endTime)) resultfile = collect.crawling(**item, fetch=False) item['resultfile'] = resultfile # 데이터 분석(analyze) --> konlpy(...jpype --> +java 64bit, python 64bit 비트 맞춰야함) for item in items: endTime = time.time() - startTime print('Running analyze : ' + str(endTime)) data = analyze.json_to_str(item.get('resultfile'), 'message') item['count_wordfreq'] = analyze.count_wordfreq(data) # 데이터 시각화(visualize) for item in items: endTime = time.time() - startTime print('Running visualize : ' + str(endTime))
import collect import analyze import visualize from config import CONFIG if __name__ == '__main__': # print('analysis_fd 프로젝트 __main__ 실행') # items = [ # {'pageName': 'jtbcnews', 'since': '2018-01-01', 'until': '2018-06-14'}, # {'pageName': 'chosun', 'since': '2018-01-01', 'until': '2018-06-14'} # ] #데이터 수집(collection) for item in CONFIG['items']: resultfile = collect.crawling(**item, **CONFIG['common']) # *item은 튜블일 경우, **item은 딕셔너리일 경우 item['resultfile'] = resultfile #데이터 분석 for item in CONFIG['items']: # print(item['resultfile']) data = analyze.json_to_str(item['resultfile'], 'message') print(data) item['count_wordfreq'] = analyze.count_wordfreq(data) print(item['count_wordfreq']) #데이터 시각화(visualize) for item in CONFIG['items']: count = item['count_wordfreq'] count_m50 = dict(count.most_common(50))
# from analysis_fb.collect import crawler as cw # cw.crawling("jtbcnews", # "2017-01-01", # "2017-12-31") #조선, jtbc, 뭐무머뭐 다 적어주면됨 구지 하위파일을 안건들여도됨 # print('run analysis_fb....') import collect if __name__ == '__main__': items = [{ 'pagename': "jtbcnews", "since": "2017-01-01", "until": "2018-12-31" }, { 'pagename': "chosun", "since": "2017-01-01", "until": "2018-12-31" }] #데이터 수집 for item in items: collect.crawling(**item) # 데이터 분석(analyze) collect.crawling("jtbcnews", "2017-01-01", "2018-12-31") # 데이터 시각화(visualize)
#from analysis_fb.collect import crawler as cw #from collect import crawler as cw # cmd에서 출력할 때 from analyze import analyzer as analyze import collect from config import CONFIG import visualize # import analyze # import visualize if __name__ == '__main__': for pagename in CONFIG['pagename']: collect.crawling(pagename, **CONFIG['common']) # items = [ # {'pagename' : 'jtbcnews', 'since' : '2017-01-01', 'until' : '2017-12-31'}, # {'pagename' : 'chosun', 'since' : '2017-01-01', 'until' : '2017-12-31'} # ] # 데이터 수집(collection) # for item in items: # collect.crawling(**item) # collect.crawling( # "jtbcnews", # '2017-01-01', # '2017-12-31') # 데이터 분석(analyze) # 데이터 시각화(visualize)
import collect import analyze import visualize #실행파일과 라이브러리파일 구분 if __name__ == '__main__': #실행파일이면, ''' items = [ {'pagename': 'jtbcnews', 'since': '2017-01-01', 'until': '2017-12-31'}, {'pagename': 'chosun', 'since': '2017-01-01', 'until': '2017-12-31'} ] #어떤놈수집할까 항목저장 ''' items = [] #데이터 수집(collection) for pagename in CONFIG['pagename']: resultfile = collect.crawling( pagename, **CONFIG['common']) # 데이터는 수집않고 파일명만 가져오게 items.append({'pagename': pagename}) for item in items: item['since'] = CONFIG['common']['since'] item['until'] = CONFIG['common']['until'] item['resultfile'] = resultfile print('resultfile items :', items) ''' for item in items: resultfile = collect.crawling(**item, fetch=False)#데이터는 수집않고 파일명만 가져오게 item['resultfile'] = resultfile ''' #데이터 분석(analyze)items.append({ 'resultfile': resultfile }) for item in items: data = analyze.json_to_str(item['resultfile'],