#!/bin/env python
#
# you can also use the script directly from gnuplot and even not saving it
#
# python get_spiacs.py '2011-07-31T11:08:30.0 30'
#
# gnuplot> plot "< python get_spiacs.py '2011-07-31T11:08:30.0 30'" u 2:3
#
# gnuplot> plot "< curl http://isdc.unige.ch/~savchenk/spiacs-online/get_spiacs.py | python - '2011-07-31T11:08:30.0 30'" u 2:3
#
try:
from urllib2 import urlopen
except:
from urllib.request import urlopen
try:
from urllib import urlencode
except:
from urllib.parse import urlencode
import sys
import re
utc=sys.argv[1]
resp=urlopen("http://www.isdc.unige.ch/~savchenk/spiacs-online/spiacs.pl?%s"%urlencode({"requeststring": utc,'submit':"Submit", 'generate':'ipnlc'})).read()
try:
resp = resp.decode()
except:
pass
print(re.sub("^(\n|.)*result:","",re.sub("
","\n",resp),re.S))
#print re.sub("^(\n|.)*result:","",re.sub("#.*?\n","",re.sub("
","\n",resp),re.M),re.S)