Created
October 15, 2009 23:58
-
-
Save Synesso/211409 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 java.util.regex._ | |
import java.net._ | |
import scala.xml._ | |
import scala.io._ | |
def inputValue(s: String, n: String) = { | |
val headless = s.substring(s.indexOf("name=%s value=\"".format(n))+ 13 + n.length) | |
headless.substring(1, headless.indexOf("\">")) | |
} | |
val loginPage = Source.fromURL("https://servicedesk.sensis.com.au/CAisd/pdmweb.exe").mkString("") | |
val sid = inputValue(loginPage, "SID") | |
val fid = inputValue(loginPage, "FID") | |
val user = "user" | |
val pass = "pass" | |
val url = "https://servicedesk.sensis.com.au/CAisd/pdmweb.exe?SID=%s&FID=%s&PortalSession=&USERNAME=%s&screenReader=No&PIN=%s&PDA=No&OP=LOGIN".format(sid, fid, user, pass) | |
val loggedInPage = Source.fromURL(url).mkString | |
val x_url = new URL("http://servicedesk.sensis.com.au/CAisd/pdmweb.exe") | |
val x_urlConn = x_url.openConnection | |
x_urlConn.setDoInput(true) | |
x_urlConn.setDoOutput(true) | |
x_urlConn.setUseCaches(false) | |
x_urlConn.setRequestProperty("User-Agent", "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.14) Gecko/2009090217 Ubuntu/9.04 (jaunty) Firefox/3.0.14") | |
x_urlConn.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") | |
x_urlConn.setRequestProperty("Accept-Language", "en-us,en;q=0.5") | |
x_urlConn.setRequestProperty("Accept-Encoding", "gzip,deflate") | |
x_urlConn.setRequestProperty("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7") | |
x_urlConn.setRequestProperty("Referer", "http://servicedesk.sensis.com.au/CAisd/pdmweb.exe?OP=JUST_GRONK_IT+SID=1888969537+FID=1234+HTMPL=load_wait.htmpl+KEEP.cstm_scbd_id=+KEEP.new_htmpl=scoreboard.htmpl+KEEP.wait_msg=553") | |
x_urlConn.setRequestProperty("Cache-Control", "max-age=259200") | |
x_urlConn.setRequestProperty("Connection", "keep-alive") | |
val x_out = new DataOutputStream(x_urlConn.getOutputStream) | |
x_out.writeUTF("OP=JUST_GRONK_IT+SID=%s+FID=8203+HTMPL=scoreboard.htmpl+KEEP.cstm_scbd_id=+KEEP.USQ_OWNER=+KEEP.USQ_OWNER_SYM=".format(sid)) | |
x_out.flush | |
x_out.close | |
val x_in = x_urlConn.getInputStream | |
println(Source.fromInputStream(x_in).mkString("")) | |
x_in.close | |
// val scoreboardURL = "https://servicedesk.sensis.com.au/CAisd/pdmweb.exe?OP=JUST_GRONK_IT+SID=%s+FID=%s+HTMPL=scoreboard.htmpl+KEEP.cstm_scbd_id=+KEEP.USQ_OWNER=+KEEP.USQ_OWNER_SYM=".format(sid, fid) | |
// val scoreboardHTML = Source.fromURL(scoreboardURL).mkString |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment