Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to post an altered html page back to the site in applescript?

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.

Posted on Jan 16, 2012 5:29 PM

Reply
Question marked as Best reply

Posted on Jan 16, 2012 7:46 PM

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

15 replies

Jan 17, 2012 2:24 AM in response to ra5ul

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

Jan 17, 2012 3:57 AM in response to s.i.m

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.

Jan 17, 2012 7:33 AM in response to ra5ul

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?

Jan 17, 2012 2:21 PM in response to s.i.m

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.

Jan 17, 2012 4:24 PM in response to s.i.m

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.

Jan 18, 2012 3:24 AM in response to ra5ul

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');"

Jan 20, 2012 6:24 PM in response to s.i.m

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.

How to post an altered html page back to the site in applescript?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.