Saturday, June 30, 2012

Parsing Data For Fun , using Google App Engine Python

Hi ,

I just wanted to know about recent movies that are running in theaters near my location ,so i just wanted to create an alert that sends fb messages and sms frequently regarding the latest movie running in the theater near me.
To create this i used Google's App engine to create a python app witch is automatically invoked periodically as a Cron job .

Getting started with app engine using this link:
https://developers.google.com/appengine/docs/python/gettingstartedpython27/

I parsed the movies name by parsing the website  entertainment.oneindia.com and cron will execute the below script to get the movie name.....




import urllib
from google.appengine.api import mail
print 'Content-Type: text/plain'
print ''
try:
    url=urllib.urlopen("http://entertainment.oneindia.in/movie_listings/Bangalore+Lakshmi+Theatre.html");
    content=url.read()
    movie_name=content[content.find('25527878</td>')+13:content.find("<td class = 'm10' >10.00 AM")]
    movie_name=movie_name[movie_name.find("<td class = 'm10' >")+19:movie_name.find("</td>")];
    print "SMS notifier by vengad:Laskshmi theater:",movie_name
    mail.send_mail(sender="Lakshmi theater Information <fantastic.next@gmail.com>",
              to="Admin <vengadanathan@facebook.com>,Way2sms <2way2sms-for-sms-alert@way2sms.com>,friend <my-friend@facebook.com>",
              subject="Alert!!"+movie_name+" running on Lakshmi Theater tavarekere",
              body="""Hi ,
               Recent movie that is running on Lakshmi Theater tavarekere is """+movie_name+"""
               Report Generated by mail-alert App By vengadanathan""")
except:
    print "Sorry I was unable to retrive movie info"


The cron that i have created is


cron:
- description: movie alert
  url: /movie-alert
  schedule: every friday 12:00



so i will be getting movie alerts on every Friday Noon i.e the day new movies get released :)..
I added my friend's email id to the list so he will be also notified..


This app was created to eat time when i was alone in weekend without friends as a time pass...

1 comment: