1

I am trying to see if it is all possible to login to a website after which I will make calls to extract some data. I am doing the latter from one website which doesn't require a login as so:

doc = Jsoup.connect("https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs").data("retrieveLocId", params[0])
                    .data("formatType", "ICAO").data("reportType", "RAW").data("actionType", "notamRetrievalByICAOs")
                    // .userAgent("Mozilla")
                    // .cookie("auth", "token")
                    .timeout(6000).post();

This is working perfectly so I want to do the same thing on this other website but I need to login first.

So I have stripped the webpage down to the barest amount to try and see what is required to make the login work and I have the following:

<script src="https://www.airservicesaustralia.com/naips/Scripts/2012.1.214/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="https://www.airservicesaustralia.com/naips/Scripts/jquery-ui-1.8.18.custom.min.js" type="text/javascript"></script>

<form action="https://www.airservicesaustralia.com/naips/Account/LogOn" id="frmLogon" method="post">

    <input name="UserName" value="login_goes_here" />  
    <input   name="Password" value="password_goes_here"/> 
    <input type="hidden" value="Submit" data-type="submit" />

</form>
<script src="https://www.airservicesaustralia.com/naips/Scripts/napis/naips.js?v0.0076" type="text/javascript"></script>

If I press the submit button now the login succeeds. However, I have now run out of knowledge about how this whole thing works in terms of the scripts. So my question at this stage is, is it even possible to construct a call from within Android to get a successful login such that I can then use the same style of jsoup.connect I am currently using?

I am thinking I have to look at the naips.js script and perhaps find out what it is finally using to submit but I'm not sure. Any help would be appreciated.

Gavin...

Gavin
  • 460
  • 4
  • 11
  • Cant answer for 8 hours so: I actually solved this by looking at the element information in Chrome. I could see the submit button that the javascript was creating and then I just manually put that into the HTML and then could remove all the scripts! Now just have to work out how to collect the cookies when they come back! – Gavin Dec 06 '13 at 07:11
  • Take a look at this for session cookies: http://stackoverflow.com/questions/6432970/jsoup-posting-and-cookie – Daniel B Dec 06 '13 at 13:00
  • Gavin please post your comment as an answer and accept it. It will be easier for future viewers, also you've gained the right for those karma points :P – Alkis Kalogeris Dec 06 '13 at 22:41

1 Answers1

0

I actually solved this by looking at the element information in Chrome. I could see the submit button that the javascript was creating and then I just manually put that into the HTML and then could remove all the scripts

Gavin
  • 460
  • 4
  • 11