VTS 초보

This commit is contained in:
암냥 2025-03-02 23:23:45 +09:00
commit 4140406c88
4 changed files with 56 additions and 51 deletions

View file

@ -1,57 +1,37 @@
import requests, datetime
from bs4 import BeautifulSoup
import openpyxl, os
import openpyxl, os, json
def get_board():
url = "http://isangjeong.icems.kr/boardCnts/list.do?searchType=S&page=1&boardID=33523&prntBoardID=0&prntBoardSeq=0&prntLev=0&m=0601&s=isangjeong"
with open('./config.json') as json_file:
json_data = json.load(json_file)
KEY = json_data['KEY']
ROOT = json_data['ROOT']
font = f"{ROOT}/library/Pretendard-Bold.ttf"
WEBHOOK_URL = json_data['WEBHOOK_URL']
response = requests.get(url)
path = f'{ROOT}temp/downloaded_file.xlsx'
soup = BeautifulSoup(response.text, "html.parser")
element = soup.select_one("html body div:nth-of-type(2) div:nth-of-type(3) div div:nth-of-type(2) section:nth-of-type(2) div:nth-of-type(2) div:nth-of-type(2) div:nth-of-type(2) div form table tbody tr:nth-of-type(1) td:nth-of-type(2) a")
onclick_value = element.get("onclick")
values = str(onclick_value[18:-1].replace("'", "")).replace(" ", "").split(",")
# for i in values:
# print(i)
return f"http://isangjeong.icems.kr/boardCnts/updateCnt.do?boardID={values[0]}&viewBoardID={values[1]}&boardSeq={values[2]}&lev={values[3]}"
path = f'{os.getenv('ROOT')}temp/downloaded_file.xlsx'
def download(url:str):
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")
element = soup.select_one("html > body > div:nth-of-type(2) > div:nth-of-type(3) > div > div:nth-of-type(2) > section:nth-of-type(2) > div:nth-of-type(2) > div:nth-of-type(2) > div:nth-of-type(2) > div > form > table > tbody > tr:nth-of-type(2) > td > p > a:nth-of-type(1)")
herf_value = element.get("href")
response = requests.get("http://isangjeong.icems.kr"+herf_value)
def download():
response = requests.get("https://f.imnya.ng/.today.isangjeong/vts.xlsx")
with open(path, "wb") as file:
file.write(response.content)
def get_vts():
#download(get_board())
ws = openpyxl.load_workbook(path).active
vts_list = []
for row in ws.iter_rows(min_row=5, max_row=5, min_col=7, max_col=14):
def detect_vts_day():
# 엑셀 파일 로드
ws = openpyxl.load_workbook(path, data_only=True).active
# 노란색 색상 코드
yellow_color = "FFFFFF00"
# 색상이 있는 셀 확인
vts_days = []
for row in ws.iter_rows(min_row=5, max_row=5):
for cell in row:
if cell.fill.start_color.index == 'FFFFFF00':
value = str(cell.value).split('(')[0].strip()\
.replace(" ", "")\
.replace("", "")\
.replace("", "")
vts_list.append(f"{datetime.datetime.today().year}{value}")
return vts_list
if cell.fill and cell.fill.start_color.index == yellow_color:
vts_days.append(cell.value.split(" ")[1].replace("", "").replace("(", "").replace(")", "")[:-1])
def get_vts_true_or_false():
vts_list = get_vts()
today = datetime.datetime.today().strftime("%Y%m%d")
if today in vts_list:
return True
else:
return False
return False
return vts_days
def VTS임(MSLV_YMD:str):
return str(MSLV_YMD)[-2:] in detect_vts_day()