Skip to content

Instantly share code, notes, and snippets.

@csy1204
Created May 10, 2019 08:33
Show Gist options
  • Save csy1204/35a78bcc95bf91203ce1bf8e0c4e3e01 to your computer and use it in GitHub Desktop.
Save csy1204/35a78bcc95bf91203ce1bf8e0c4e3e01 to your computer and use it in GitHub Desktop.
import telegram #텔레그램 모듈을 가져옵니다.
import requests
from bs4 import BeautifulSoup
import time
url = "http://ticket.cgv.co.kr/CGV2011/RIA/CJ000.aspx/CJ_002_PRIME_ZONE_LANGUAGE"
payload = str(//CGV PAYLOAD//)
headers = {
'Accept': "application/json, text/javascript, */*; q=0.01",
'Content-Type': "application/json",
'Origin': "http://ticket.cgv.co.kr",
'Referer': "http://ticket.cgv.co.kr/Reservation/Reservation.aspx?MOVIE_CD=&MOVIE_CD_GROUP=&PLAY_YMD=&THEATER_CD=&PLAY_NUM=&PLAY_START_TM=&AREA_CD=&SCREEN_CD=&THIRD_ITEM=",
'User-Agent': "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36",
'X-Requested-With': "XMLHttpRequest",
'cache-control': "no-cache",
}
pay_list = [payload]
bot = telegram.Bot(token='//Telegram Bot TOKEN//' )
chat_id = bot.getUpdates()[-1].message.chat.id
print(chat_id)
bot.sendMessage(chat_id=chat_id, text='안녕하세요')
while True:
for i, pay in enumerate(pay_list):
response = requests.request("POST", url, data=pay, headers=headers)
data = response.json()
s = data['d']['data']['DATA']
soup = BeautifulSoup(s,'lxml')
seat_infos = (soup.find_all('seat_info'))
for seat in seat_infos:
if seat.find('seat_state').text == 'Y' and (16 <= int(seat.find('seat_no').text) <= 29) and (8 <= int(seat.find('loc_y').text) <= 13):
print('Yes')
bot.sendMessage(chat_id=chat_id, text='{}번째 회차에 자리가 생겼습니다!'.format(i))
time.sleep(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment