Skip to content

Instantly share code, notes, and snippets.

@thefinn93
Created January 29, 2015 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thefinn93/5b2b9392b43b8ca01104 to your computer and use it in GitHub Desktop.
Save thefinn93/5b2b9392b43b8ca01104 to your computer and use it in GitHub Desktop.
Check kimsufi's availability and emails you when they've got open slots. one argument, the sort code or identifier they use for the type of server. To get it, inspect their HTML, the <tr> has a property of data-ref with the value you need. It changes sometimes too
#!/usr/bin/env python
## Usage: ./getAvailability.py 150sk20
## Remember to fill in that shit down there first
import sys
import json
import requests
import time
import smtplib
SMTP_USERNAME = 'yep@lol.net'
SMTP_PASSWORD = 'hunter2'
SMTP_FROM = SMTP_USERNAME
SMTP_SERVER = 'mail.lol.net:587'
SMTP_TO = ['me@lol.net', '2024561414@txt.att.net']
INTERVAL = 60
while True:
try:
availability = requests.get("https://ws.ovh.com/dedicated/r2/ws.dispatcher/getAvailability2").json()
for serverType in availability['answer']['availability']:
if serverType['reference'] in sys.argv or len(sys.argv) == 1:
for zone in serverType['zones']:
if zone['availability'] != "unavailable":
mailserver = smtplib.SMTP(SMTP_SERVER)
mailserver.starttls()
mailserver.login(SMTP_USERNAME, SMTP_PASSWOD)
message = "%s is %s in %s (AKA OMG KIMSUFI'S! GET EM WHILE THEY'RE HOT!!)" % (serverType['reference'], zone['availability'], zone['zone'])
mailserver.sendmail(SMTP_FROM, SMTP_TO, message)
print message
time.sleep(300)
except Exception as e:
print e
time.sleep(INTERVAL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment