Created
December 12, 2012 06:47
-
-
Save dreampuf/4265597 to your computer and use it in GitHub Desktop.
Interval tool for check buyvm.net activate Instance send email to inform your by email
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#vi: encoding=utf-8 | |
""" Interval tool for check buyvm.net activate Instance send email to inform your by email | |
http://huangx.in | |
""" | |
import time | |
import json | |
import urllib2 | |
import smtplib | |
from contextlib import closing | |
from email.MIMEText import MIMEText | |
TARGET = 'http://www.doesbuyvmhavestock.com/automation.json' | |
EMAIL_USERNAME = "your mandrillapp account" | |
EMAIL_PASSWORD = "your mandrillapp key" | |
EMAIL_TARGET = "your email address" | |
WANTER = ("SJ OpenVZ-128MB", | |
"SJ KVM-128MB", | |
"NY OpenVZ-128MB", | |
"NY KVM-128MB") | |
while True: | |
with closing(urllib2.urlopen(TARGET)) as f: | |
d = json.loads(f.read()) | |
want = [i for i in d if i["name"] in WANTER and i["qty"] > 0] | |
if want: | |
content = str(want) | |
email_server = smtplib.SMTP("smtp.mandrillapp.com", port=587) | |
email_server.login(EMAIL_USERNAME, EMAIL_PASSWORD) | |
msg = MIMEText(content, "html", "utf-8") | |
msg["From"] = "[email protected]" | |
msg["Subject"] = "BUYVM come!" | |
msg["To"] = EMAIL_TARGET | |
email_server.sendmail("[email protected]", EMAIL_TARGET, msg.as_string()) | |
time.sleep(300) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment