원래 계획은 원하는 프로그램을 검색, 조회 기능까지 넣는 것이었지만, 우선 채널 편성표를 출력하는 기능만 구현한 후 나중에 추가해야겠다.
채널은 투니버스와 애니박스를 골랐다. 다행히 두 사이트의 편성표를 날짜별로 조회하는 것은 쉬웠다.
tooni_url = "http://tooniverse.tving.com/tooniverse/schedule?startDate="+today
anibox_url = "http://aniboxtv.com/schedule/day.php?prev=" + year + "-" + month + "-" + day
urllib.request을 통해 html 코드를 가져오고 BeautifulSoup로 파싱하였다. 두 패키지를 통해 날짜별 편성표를 크롤링한 후 조금 다듬어 데이터프레임으로 만든 후 html로 변환하였다.
htmlcode = urllib.request.urlopen(tooni_url).read()
soup = BeautifulSoup(htmlcode, "html.parser")
timetable_df.to_html("toon" + today + ".html", justify='center')
코드는 아래 링크에 있다.
github.com/cheogodzip/shintv/blob/main/make_table.py
cheogodzip/shintv
투니버스 애니박스 편성표 조회. Contribute to cheogodzip/shintv development by creating an account on GitHub.
github.com
이후 계획은 파이썬으로 두 채널의 일자별 편성표를 합쳐 html을 작성하는 코드를 짤 예정이다.
'study > python' 카테고리의 다른 글
파이썬 for문과 리스트 원소 제거 주의 (2) | 2021.03.03 |
---|---|
파이썬 문법 정리 (0) | 2021.01.01 |
파이썬/HTML 방송 편성표 사이트 만들기(1) (0) | 2020.12.28 |
파이썬 데이터프레임 아이템 리스트 .to_sql() 에러 (0) | 2020.12.27 |