-
-
Save embeddeduser/de7bcc8a30541011770533708e1e0f5f to your computer and use it in GitHub Desktop.
This file contains 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
import logging | |
import requests | |
import lxml.html | |
import sys | |
sat = "40014" #SAT norrad_cat_id | |
transmitter = "NSXo8tGxmxpTUMsmSH34FF" #Transmitter UUID | |
start="2017-12-1 17:00" #Start date and time | |
end="2017-12-2 03:00" #Stop date and time | |
Schedule = False #Just show don't schedule | |
username = "" | |
password = "" | |
session = requests.session() | |
loginUrl = "https://network-dev.satnogs.org/accounts/login" #login URL | |
login = session.get(loginUrl) #Get login page for CSFR token | |
login_html = lxml.html.fromstring(login.text) | |
login_hidden_inputs = login_html.xpath(r'//form//input[@type="hidden"]') #Get CSFR token | |
form = {x.attrib["name"]: x.attrib["value"] for x in login_hidden_inputs} | |
form["login"]=username | |
form["password"]=password | |
session.post(loginUrl,data=form,headers={'referer':loginUrl}) #Login | |
q=session.get("https://network-dev.satnogs.org/prediction_windows/"+sat+"/"+transmitter+"/"+start+"/"+end+"/") #Get prediction_windows | |
obsURL = "https://network-dev.satnogs.org/observations/new/" #Observation URL | |
obs = session.get(obsURL) #Get the observation/new/ page to get the CSFR token | |
obs_html = lxml.html.fromstring(obs.text) | |
hidden_inputs = obs_html.xpath(r'//form//input[@type="hidden"]') | |
form = {x.attrib["name"]: x.attrib["value"] for x in hidden_inputs} | |
form["satellite"]=sat | |
form["transmitter"]=transmitter | |
form["start-time"]="2017-11-29 14:45"#start | |
form["end-time"]="2017-11-29 14:58" | |
windows = q.json() | |
current = 0 | |
#print q.text | |
for x in windows: | |
station = x["id"] | |
print "\nStation "+x["name"],x["id"] | |
for y in x["window"]: | |
print "Observation "+str(current) | |
print y["start"] | |
print y["end"] | |
print "-"*20 | |
current+=1 | |
current = 0 | |
for x in windows: | |
station = x["id"] | |
for y in x["window"]: | |
form[str(current)+"-starting_time"] = y["start"] | |
form[str(current)+"-ending_time"] = y["end"] | |
form[str(current)+"-station"] = station | |
current+=1 | |
form["total"]=str(current) | |
if Schedule and current > 0: | |
r = session.post(obsURL,data=form,headers={'referer':obsURL}) | |
print r.cookies.items() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment