-
Notifications
You must be signed in to change notification settings - Fork 0
/
movie_crawler.py
36 lines (30 loc) Β· 1.34 KB
/
movie_crawler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import requests
from bs4 import BeautifulSoup
from datetime import datetime
from telegram_message import *
current_date = datetime.now().strftime('%Y%m%d')
def run_crawler(movie_date):
url = "http://www.cgv.co.kr/common/showtimes/iframeTheater.aspx?areacode=01&theatercode=0013&date="+movie_date
html = requests.get(url)
soup = BeautifulSoup(html.text, 'html.parser')
movie_list = soup.select('div.col-times')
return get_imax_movies(movie_list)
#λͺ¨λ μν μ€ imax μμκ΄μ΄ νμλμ΄ μλ μνλ§ μΆμΆ
def get_imax_movies(movie_list):
movie_titles = []
for movie in movie_list:
movie_title = movie.select_one('div.info-movie > a > strong').text.strip()
if movie.select_one('span.imax'):
movie_titles.append(movie_title)
return movie_titles
def check_movie_list(imax_movie_list, movie_date):
if imax_movie_list:
if current_date == movie_date:
current_message = "μ€λ"
else:
current_message = movie_date+"μ"
current_message += " IMAX μλ§€κ° μ΄λ¦¬λ μνλ "+', '.join(imax_movie_list)+"μ
λλ€!"
add_message = '\n λ€λ₯Έ λ μ§μ IMAX μ€ν μνλ₯Ό μκ³ μΆλ€λ©΄ YYYYMMDD ννλ‘ λ μ§λ₯Ό μ
λ ₯ν΄μ£ΌμΈμ!'
send_bot_message(current_message+add_message)
return True
return False