Skip to content

Instantly share code, notes, and snippets.

@EarlGlynn
Created May 5, 2015 14:13
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 EarlGlynn/5534c8c730cd0ac346f1 to your computer and use it in GitHub Desktop.
Save EarlGlynn/5534c8c730cd0ac346f1 to your computer and use it in GitHub Desktop.
Download selected Missouri professional registration files
#! /usr/bin/python
# Download selected Missouri professional registration files from
# http://pr.mo.gov/listings.asp
# Typically run via a cron job, e.g., grab at 6:05 AM every Sunday:
# min(0-59) hr(0-23) day(1-31) month(1-12) weekday(0-6) command
# 05 6 * * 0 /home/xxxxxx/data/Missouri-Licenses/get-MOLicenses.py >/dev/null 2>&1
# efg, UMKC CHI, 1 Aug 2014.
import urllib
import os
import time
import datetime
from subprocess import *
os.chdir("/home/xxxxxx/data/Missouri-Licenses/")
ts = time.time()
timestamp = datetime.datetime.fromtimestamp(ts).strftime('%Y%m%d-%H%M%S')
if not os.path.exists(timestamp):
os.makedirs(timestamp)
# Missouri professional registrations to grab
files = [
('Dentistry', 'Dentist', 'DEN.ZIP'),
('Dentistry', 'DentalHygienist', 'DHY.ZIP'),
('Nursing', 'RegisteredNurse', 'ORN.ZIP'),
('Nursing', 'LicensedPracticalNurse', 'LPN.ZIP'),
('Optometry', 'Optometrist', 'OPT.ZIP'),
('Pharmacy', 'Pharmacist', 'PHA.ZIP'),
('Pharmacy', 'Pharmacy', 'PHY.ZIP'),
('HealingArts', 'Audiologist', 'AUD.ZIP'),
('HealingArts', 'MedicalPhysicianSurgeon', 'MED.ZIP'),
('HealingArts', 'OsteopathicPhysicians', 'OPS.ZIP'),
('HealingArts', 'PhysicianAssistant', 'PYA.ZIP'),
('Psychology', 'Psychologist', 'PSY.ZIP')
]
# Download ZIP files in timestamp directory
for license_file in files:
fromfile = "http://pr.mo.gov/downloadables/" + license_file[2]
tofile = timestamp + "/" + license_file[0] + "-" + license_file[1] + "-" + license_file[2]
urllib.urlretrieve(fromfile, filename=tofile)
# Send E-mail confirmation
readBody = Popen(["/bin/ls", "/home/xxxxxx/data/Missouri-Licenses/"+timestamp], stdout=PIPE)
mail = Popen(["/bin/mailx", "-s", "get-MOLicences.py", "xxxxxx@xxxx.edu"], stdin=readBody.stdout, stdout=PIPE)
output = mail.communicate()[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment