Previous 1 2 Next 15 Replies Latest reply: Jan 21, 2012 5:29 AM by s.i.m
s.i.m Level 1 (0 points)

Hi guys,

I have been wanting to get live quotes through my brokerage account and I know how to alter the html to log in: I set value after username in html and fill in the username, and i do the same for the password. As I can see in firebug the html shows that i filled in password and username.

I know how to get the html by curling an url in applescript by do shell. I also know how to assign it to a variable and how to alter it.  After i assigned the html with login information back to the site i and it is assigned to a variable such as html. How do i do this? imagine my altered html is in a variable and i want it send to a site to get the response page? Then i will have access to the live quotes:D and i can supply my numbers page with accurate information to supply my stochastic models.

  • ra5ul Level 3 (500 points)

    this exposes your password.  are you just trying to automatically log in?  there may be a better way of doing this than applescript.

  • s.i.m Level 1 (0 points)

    such as? and i trust the site completely and i really wish to learn it this day as well...:P So can you explain me what else i can do to login with script? because i need the live stock quotes. Can you also show me how to post an altered html page, i know how to curl it but how to put it back:S

  • s.i.m Level 1 (0 points)

    way*

  • ra5ul Level 3 (500 points)

    such as forcing the site to remember your login details, or scripting the site within safari using a bookmarklet, but i would have to examine the actual site code to give you those details.

     

    it's possible to cURL a page, edit the html (optionally adding a <base href> to the <head> section) and then just open the file in safari which would in a sense be posting an altered html page.

  • s.i.m Level 1 (0 points)

    https://login.binck.nl/klanten/Login.aspx?ReturnUrl=%2fklanten%2fdefault.aspx

    this is the site:) , Could you show me how to force the site to remember my password or script within safari?

    So if i curl the page and assign a variable and it is in html and i put in the login and password value, i know how to do this in html. Then what do i curl to get the login page? do i just curl the variable html for example? everything is now in the html file log in information and such... but how do i use applescript to curl the page that comes up when i normally press login on this site?

  • ra5ul Level 3 (500 points)

    here's an example applescript that will autologin you in (replace 'sim' and 'password' with your actual login details):

     

    do shell script "open -a safari 'https://login.binck.nl/klanten/Login.aspx?ReturnUrl=%2fklanten%2fdefault.aspx'"

    tell application "Safari"

      activate

              tell document 1

                        repeat until ((do JavaScript "location.host") is "login.binck.nl")

                                  delay 1

                        end repeat

      do JavaScript "document.getElementById('ctl00_Content_Gebruikersnaam').value='sim';document.ge tElementById('ctl00_Content_Wachtwoord').value='password';window.open(document.g etElementById('ctl00_Content_LoginButton').href, '_self', 'true');"

              end tell

    end tell

     

    there are other ways that don't expose your password but apparently that's not a concern and you seem keen on using applescript.

  • s.i.m Level 1 (0 points)

    I am not really keen on applescript, i just have no ideas what other ones could be?:S

  • s.i.m Level 1 (0 points)

    and it doesnt seem to work:( sorry i bother you so much but i really want to know this:(

  • ra5ul Level 3 (500 points)

    i think the code got mangled when i posted it.  here it is unformatted:

     

    do shell script "open -a safari 'https://login.binck.nl/klanten/Login.aspx?ReturnUrl=%2fklanten%2fdefault.aspx'"

    tell application "Safari"

      activate

        tell document 1

          repeat until ((do JavaScript "location.host") is "login.binck.nl")

            delay 1

          end repeat

          do JavaScript "document.getElementById('ctl00_Content_Gebruikersnaam').value='YOURLOGIN';docu ment.getElementById('ctl00_Content_Wachtwoord').value='YOURPASSWORD';window.open (document.getElementById('ctl00_Content_LoginButton').href, '_self', 'true');"

        end tell

    end tell

     

    again, remember to replace your login and password with the actual values and if it still doesn't work post back with the result from applescript.

  • ra5ul Level 3 (500 points)

    sorry, the code got mangled again.  this is what the long line should be:

     

     

    do JavaScript "document.getElementById('ctl00_Content_Gebruikersnaam').value='YOURLOGIN';document.getElementById('ctl00_Content_Wachtwoord').value='YOURPASSWORD';window.open(document.getElementById('ctl00_Content_LoginButton').href, '_self', 'true');"
  • s.i.m Level 1 (0 points)

    Thank you so much:) As soon as i get home i will try it on my mac:) You are great man thanks for taking the time to help me out, i will post back the results, can't wait:)

  • s.i.m Level 1 (0 points)

    It worked:)))

  • s.i.m Level 1 (0 points)

    Your script works excellent but i have another question regarding this, when the site that i logged into is not selected, the internet browser window with this site in it. How can i prevent it from closing after i am not viewing the page currently.

  • ra5ul Level 3 (500 points)

    i don't know what you mean.  does the script behave any differently than when you log in manually?  i can't test any further pages since i don't have a password.

     

    the reason safari isn't offering to save your login info. is that the site is masking both the userid and password so, if it were me, i would force the site to unmask the userid with a greasemonkey script rather than try and automate it with applescript.  this requires an extension, but it's something you could look into if you start running into more sites that you would like to automate/manipulate.

Previous 1 2 Next