Guest User

Untitled

a guest
Oct 21st, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. #!/usr/bin/env python2.7
  2. import urllib2
  3. from bs4 import BeautifulSoup
  4. import re
  5. import smtplib
  6. import time
  7.  
  8. site= "https://in.bookmyshow.com/buytickets/namaste-england-goa/movie-goa-ET00069350-MT/" #Replace this your movieandcity url
  9. date="20181022" #replace the date with the date for which you'd like to book tickets! Format: YYYYMMDD
  10. site=site+date
  11. hdr = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
  12. 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  13. 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
  14. 'Accept-Encoding': 'none',
  15. 'Accept-Language': 'en-US,en;q=0.8',
  16. 'Connection': 'keep-alive'}
  17. venue ='INMG' #this can be found by inspecting the element data-id for the venue where you would like to watch
  18. show='11:15 PM' #just replace it with your prefered show timing
  19. delay=300 #timegap in seconds between 2 script runs
  20.  
  21. TO = 'throwaway.arulmabr@gmail.com' #mail id for which you want to get alerted
  22. # Please add your username and password here, and make sure you
  23. # toggle allow less secure apps to on
  24. # https://myaccount.google.com/lesssecureapps?pli=1
  25. GMAIL_USER = 'myemailidno01@gmail.com'
  26. GMAIL_PASS = '8870202273'
  27. SUBJECT = 'Tickets are now available, Book fast'
  28. TEXT = 'The tickets are now available for the ' + show + ' show at the venue ' +venue
  29.  
  30. def send_email():
  31. print("Sending Email")
  32. smtpserver = smtplib.SMTP("smtp.gmail.com",587)
  33. smtpserver.ehlo()
  34. smtpserver.starttls()
  35. smtpserver.ehlo
  36. smtpserver.login(GMAIL_USER, GMAIL_PASS)
  37. header = 'To:' + TO + '\n' + 'From: ' + GMAIL_USER
  38. header = header + '\n' + 'Subject:' + SUBJECT + '\n'
  39. print (header)
  40. msg = header + '\n' + TEXT + ' \n\n'
  41. smtpserver.sendmail(GMAIL_USER, TO, msg)
  42. smtpserver.close()
  43.  
  44. req = urllib2.Request(site,headers=hdr)
  45. page = urllib2.urlopen(req)
  46. soup = BeautifulSoup(page)
  47. soup2=soup.find_all('div', {'data-online': 'Y'})
  48. line = str(soup2)
  49. soup3= BeautifulSoup(line)
  50. soup4=soup3.find_all('a', {'data-venue-code': venue})
  51. line1=str(soup4)
  52. soup5=BeautifulSoup(line1)
  53. soup6=soup3.find_all('a', {'data-display-showtime': show})
  54. line2=str(soup6)
  55. result=re.findall('data-availability="A"',line2)
  56. if len(result)>0:
  57. print ("Available")
  58. send_email()
  59. else :
  60. print ("Not available yet")
  61. time.sleep(delay)
Add Comment
Please, Sign In to add comment