inflearn logo
강의

Course

Instructor

Creating a movie ticket opening notification using Python

Crawling through the titles of IMAX movies that are open for pre-order

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

330

hongjunhyeok

5 asked

0

.

python

Answer 1

1

sm40462595

저도 궁금해서 한번 코드 작성해보았는데, 여러개도 알림이 가도록 구현이 가능하네요! 
참고로 저는 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()

0

hongjunhyeok

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

0

sm40462595

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

좋은 하루 보내세요~!

토큰을 통해서 제 고유아이디를 알아내야되는데 반환되는것이 하나도 없음

0

83

1

텔레그램 API가 업데이트 되면서 이 코드로는 chat_id를 확인할 수 없습니다.

1

324

2

iframe 상영시간표 가져오기

0

575

1

python-telegram-bot 2021년 20 버전 이후

0

1111

1

현재 23.01.07 기준으로 하시는 분 계시면 보세요.

0

587

1

iframe src 흰화면

7

984

0

서버에서 동작할때 셀레리움 라이브러리 있을때 에러나는데 어떻게 하면 되죠?

0

405

1

소스파일은 없을까요 부탁드려요

0

464

0

bot.getUpdates() 실행이 안됩니다..

0

363

0

PytzUsageWarning: The zone attribute is specific to pytz's interface; please migrate to a new time zone provider

0

273

0

자꾸 에러가 납니다.

0

409

1

python-telegram-bot 설치시 계속 오류가 뜹니다

0

406

0

서버 관련 질문입니다.

0

230

0

span.imax

-1

665

1

텔레그램 질문

0

257

0

requests를 어떻게 받아야 하나요

0

289

0

socket.timeout: The read operation timed out 에러발생

0

575

0

안녕하세요^^ send message 질문있습니다!!

0

188

0

마지막 부분에서 막히네요

0

265

0

aws 회원가입

0

332

0

telegrambot.py실행

0

180

0

윈도우에서는 뭘로하는건가요

0

343

1

'bot' 변수 오류가 납니다.

0

315

1

telegram모듈이 없다고나오는데...

0

188

0