Skip to content

Instantly share code, notes, and snippets.

@ljle
Last active October 5, 2016 19:19
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 ljle/a59e65c68db8f7462a61d79e807beb5b to your computer and use it in GitHub Desktop.
Save ljle/a59e65c68db8f7462a61d79e807beb5b to your computer and use it in GitHub Desktop.
Get available appointment dates from http://citavirtual.mppeuct.gob.ve/
"""
You need to be logged in and then extract the cookie from your session.
Requires: python-tk
Usage: python <script_name> <year> <from_month> <to_month> <cookie>
Example: python get_dates.py 2016 8 10 'cookie_string'
"""
import time
import sys
import calendar
from urllib2 import Request
from urllib2 import urlopen
import Tkinter as tk
import tkMessageBox
root = tk.Tk()
root.withdraw()
not_found = True
months = {k: v for k, v in enumerate(calendar.month_abbr)}
args = sys.argv[1:]
while(not_found):
for i in range(int(args[1]) - 1, int(args[2])):
req = Request(
'http://citavirtual.mppeuct.gob.ve/index.php/registro/' +
'eventosAjax?year=' + args[0] + '&month=' + str(i)
)
req.add_header('Cookie', args[3])
resp = urlopen(req)
content = resp.read()
if content[0:2] != '[]':
tkMessageBox.showwarning(
'alert title',
'Date(s) available in ' + months[(i + 1)]
)
print(content)
not_found = False
break
else:
print('No dates available in ' + months[(i + 1)])
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment