Skip to content

Instantly share code, notes, and snippets.

@makmac213
Created January 16, 2014 13:38
Show Gist options
  • Save makmac213/8455084 to your computer and use it in GitHub Desktop.
Save makmac213/8455084 to your computer and use it in GitHub Desktop.
Check for new spoilers and send sms alert to subscribers
import urllib, time, os
from subprocess import Popen, PIPE, check_call
from BeautifulSoup import BeautifulSoup
subscribers = [
'0922xxxxxxx',
'0999xxxxxxx',
'0917xxxxxxx',
'0915xxxxxxx',
]
mtgsalvation = 'http://www.mtgsalvation.com/born-of-the-gods-spoiler.html'
def get_title():
print 'retrieving info'
req = urllib.urlopen(mtgsalvation)
html = BeautifulSoup(req.read())
return html.find(name="title").text
old_title = ''
while True:
log_file = open("mtg.log", "r")
old_title = log_file.read()
new_title = get_title()
if old_title != new_title:
# send sms
print "Sending to subscribers"
for subscriber in subscribers:
print "Sending msg to %s" % subscriber
sms_msg = "Spoiler Alert %s %s\n" % (new_title.split(' ')[-1], mtgsalvation)
proc = Popen(["gammu","sendsms","text",subscriber],
stdin=PIPE, stdout=PIPE, stderr=PIPE)
proc.stdin.write(sms_msg)
proc.stdin.flush()
stdout,stderr = proc.communicate()
print sms_msg
print stdout
print stderr
print "Message Sent"
log_file.close()
log_file = open("mtg.log", "w")
log_file.write(new_title)
log_file.close()
else:
print 'No Updates Found'
time.sleep(10)
@makmac213
Copy link
Author

http://tensixtyone.com/howto-send-sms-using-a-huawei-e160g-and-debian

sudo apt-get install gammu

using Huawei Mobile WiFi E5220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment