Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import bs4
- import time
- import smtplib
- import os
- import socket
- import sys
- import os
- from pygame import mixer
- #from gi.repository import Notify
- from email.mime.text import MIMEText
- from email.mime.image import MIMEImage
- from email.mime.multipart import MIMEMultipart
- def send_mail(data):
- username = 'bookplus12@gmail.com'
- password = 'gap5246256'
- msg = MIMEMultipart()
- text = MIMEText(data)
- msg['Subject'] = 'ALERT FROM BOOK MY SHOW'
- msg.attach(text)
- to_addr = 'akhil6030@gmail.com'
- server = smtplib.SMTP('smtp.gmail.com:587')
- server.ehlo()
- server.starttls()
- server.ehlo()
- server.login(username, password)
- server.sendmail(username, to_addr, msg.as_string())
- server.quit()
- print('Mail Sent')
- def notify_me(to_send):
- print("--------------tickets are available at -----------------------\n" +
- to_send)
- # Notify.init("Book My Show")
- # Notify.Notification.new('available at '+to_send).show()
- send_mail("---------------tickets are available at -----------" + to_send)
- to_send = ''
- # mixer.init()
- # mixer.music.load("C:\\Users\\akhil\\Desktop\\web\\Loud_Alarm_Clock_Buzzer-Muk1984-493547174.mp3")
- # mixer.music.play()
- # time.sleep(70)
- # mixer.music.stop()
- alllist = []
- allstr = ""
- to_send = ''
- num_prev_th = 0
- prethi = set()
- while 'Cinepolis: Manjeera Mall, Kukatpally' not in to_send or 'Prasads: Large Screen' not in to_send or 'PVR Forum Sujana Mall: Kukatpally, Hyderabad' not in to_send or 'PVR: Inorbit, Cyberabad' not in to_send or 'AMB Cinemas: Gachibowli' not in to_send:
- # proxies = {'http': 'http://akhil3060:map5246256@10.10.10.3:3128/',
- # 'https': 'https://akhil3060:map5246256@10.10.10.3:3128/'
- # }
- # request = requests.get('https://in.bookmyshow.com/buytickets/captain-marvel-hyderabad/movie-hyd-ET00097168-MT/20190308', proxies=proxies)
- request = requests.get(
- 'https://in.bookmyshow.com/buytickets/avengers-endgame-hyderabad/movie-hyd-ET00100559-MT/20190426'
- )
- print("status =",request.status_code)
- if request.status_code == 200:
- parser = bs4.BeautifulSoup(request.text, "html.parser")
- li = parser.select(
- 'div[class="__name "] > a[class="__venue-name"] > strong')
- length = len(li)
- # print("firsty li \n",li)
- # print("numb prev len ", allstr)
- if num_prev_th < length:
- # print(" after numb prev len ", allstr)
- mymsg = "\n\n\n This is Book my show Assistant: Now tickets are available in new theater \n =====" + allstr
- send_mail(mymsg)
- if num_prev_th != length:
- num_prev_th = length
- print(
- "=========================STARTED HERE=================================\n"
- )
- print("\nNumber of theatres available " + str(len(li)))
- # print("\n -----------------------New theaters are--------------------------- \n")
- # print("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n")
- # print("diff ",prethi.difference(set(li)))
- # for gg in prethi.difference(set(li)):
- # print("gg ",gg)
- # if gg == '':
- # print("No new theaters are available")
- # else:
- # print("this is the difference")
- # print(gg)
- # print("diff ends here")
- # # notify_me(gg)
- # send_mail("I am sendinfg the difference",gg)
- # print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n")
- print(
- "---------------------------All theaters -------------------------------\n"
- )
- r = map(lambda x: x.getText() + "\n", li)
- # print(type(r) , list(r))
- alllist = []
- allstr = ""
- for i, j in enumerate(r):
- print(i + 1, ":", j)
- allstr += j[:-2] + "\n"
- alllist.append(j[:-2])
- # print(alllist)
- for i in li:
- if 'Cinepolis: Manjeera Mall, Kukatpally' == i.getText(
- ) or 'Prasads: Large Screen' == i.getText(
- ) or 'PVR Forum Sujana Mall: Kukatpally, Hyderabad' == i.getText(
- ) or 'PVR: Inorbit, Cyberabad' == i.getText(
- ) or 'AMB Cinemas: Gachibowli' == i.getText():
- to_send += i.getText() + "\n"
- prethi = set(li)
- # print("prethi ===",prethi)
- else:
- print(
- "movie isn't available at the city you entered... I guess that the reason... Have a nice day.."
- )
- break
- if to_send == '':
- print(
- " ----------- Selected theaters are not ready yet-------------------------------\n"
- )
- # send_mail("hello no ready \n"+ allstr)
- else:
- # print(to_send)
- notify_me(to_send)
- time.sleep(20)
Add Comment
Please, Sign In to add comment