• 카테고리

    질문 & 답변
  • 세부 분야

    데이터 분석

  • 해결 여부

    미해결

만약 imax상영을 여러개 한다면 어떻게 구현을 해야되나요?

20.04.10 14:46 작성 조회수 112

0

.

답변 1

답변을 작성해보세요.

1

배성민님의 프로필

배성민

2022.01.19

저도 궁금해서 한번 코드 작성해보았는데, 여러개도 알림이 가도록 구현이 가능하네요! 
참고로 저는 imax 상영 영화 말고, tempurCinema 상영 영화로 했다는 점 유의하시길 바랍니다.
각각의 영화 별로 나눠진 col-times 클래스의 div 태그 안쪽 내용으로 반복문을 돌리며, temputCinema 클래스인 span 태그가 있는지 조건문으로 확인하고,

있다면 해당 col-times 클래스의 div 태그에 걸쳐지는 모든 영역 중 strong 태그의 텍스트를 선택하여 메시지를 전송할 수 있습니다.

import
requests
import telegram
from bs4 import BeautifulSoup
from apscheduler.schedulers.blocking import BlockingScheduler

bot = telegram.Bot(token = '5087679237:AAHASP7XCcdj26RHW20HZFt56YTzndsaZe0')
url = 'http://www.cgv.co.kr/common/showtimes/iframeTheater.aspx?areacode=01&theatercode=P013&date=20220121&screencodes=&screenratingcode=09&regioncode=103'

def job_function():
html = requests.get(url)

soup = BeautifulSoup(html.text, 'html.parser')

parent = soup.select('div.col-times')

for i in parent:
tempurCinema = i.select_one('span.tempurCinema')
if(tempurCinema):
title = i.select_one('div.info-movie > a > strong').text.strip()
bot.sendMessage(chat_id=5062868275, text=title + " tempurCinema 예매가 열렸습니다.")
sched.pause()
#else:
#bot.sendMessage(chat_id=5062868275, text = "tempurCinema 예매가 열리지 않았습니다.")
#print('tempurCinema 예매가 열리지 않았습니다.')


sched = BlockingScheduler()
sched.add_job(job_function, 'interval', seconds=5)
sched.start()
홍준혁님의 프로필

홍준혁

질문자

2022.01.20

헐 ㅠㅠㅠㅠ 제가 파이썬 꼬꼬마시절때 질문한 것을 최근에 다시 보니까 새롭네요!!ㅋㅋ 
친절히 답변해주셔서 감사합니다~

배성민님의 프로필

배성민

2022.01.20

그러고 보니, 2020년에 올라온 질문이었네요ㅋㅋ  

좋은 하루 보내세요~!