import time
import threading
import openpyxl
import win32com.client
import requests
from bs4 import BeautifulSoup
excel = win32com.client.Dispatch("Excel.Application")
#excel.Visible = True
#print(title_list)
wb = openpyxl.Workbook()
sheet1 = wb.active
html = requests.get('https://www.naver.com/').text
soup = BeautifulSoup(html, 'html.parser')
#excel_file = excel.Workbooks.Open('C:/Users/thkim/Desktop/test3.xlsx')
def thread_run():
print('=========================================================')
#title_list = soup.select('.PM_CL_realtimeKeyword_rolling')
title_list = soup.select('.PM_CL_realtimeKeyword_rolling span[class*=ah_k]')
#print(html)
for idx, title in enumerate(title_list, 1):
print(idx, title.text)
list =[idx, title.text]
sheet1.append(list)
#thread_run()
threading.Timer(20, thread_run).start()
wb.save('C:/Users/thkim/Desktop/test3.xlsx')
일단 아까 올린 글에서 run 부분은 첫 시작 땜에 한거긴 한데 일단 주석 처리 해뒀음
그리고 스타트 부분은 함수 밖으로 빼라고 해서 일단 저렇게 뺐는데
맞게 한건지 모르겠다..
돌려봐.
돌려 봤는데 1번만 출력 되고 끝나네;;;음...다시 찾아 봐야겠다 원인을..
https://niceman.tistory.com/144
일단 요거 참고 해서 했었음..
일단 몇번 돌려 봤는데 threading.Timer(20, thread_run).start() 요부분을 함수 밖에다 빼고 실행 하니깐 그냥 1번만 출력됨..혹시나 해서 시간 4초로 줄이고 해봐도 동일 증상이던데..이거 빼는게 밖에서 스타트 하려고 하는 거 아님??