The main goal of the code I posted was not download a page, but send to the router some instructions: “action → login | user → x | password → y” and “download” is the propper syntax to do it through “URL Access Scripting”.
Another eg:
tell app "URL Access Scripting"
download "http://www.google.com/search?q=macscripter" to (choose file name)
end tell
This will send “google.com” the instruction “search for macscripter” (and also, of course, you will download the response). So, for the server (google, router), this will be the same as if you manually go to google’s main page, fill a text field with “macscripter”, then press the submit button. The browser will create “on-the-fly” the propper url “http://www.google.com/search?q=macscripter” and it will call google’s method “search” (or router’s one “login” or whatever is called).
If you prefer it, you can also call this method without “URL Access Scripting” and without downloading data, and display the result in a web page:
open location "http://192.168.200.255/login?user=voltar&password=nickipicki"
Here, the browser will display the results of action “login” at host “192.168.200.255” (eg. your router’s IP): login successful, shutdown ok, whatever failed…
Also, of course, you can use Internet Explorer to do it via GUI, filling forms helped by “do script” IE’s command (execute javascript code):
tell app "Internet Explorer"
do script "document.forms[0].elements[0].value='my user name'"
end tell
This code (if you open a page with a form in Internet Explorer) will “type” the string “my user name” it the first element of the first form. A working sample: open IE, open “http://www.google.com/”, execute this code:
tell application "Internet Explorer"
do script "with(document.forms[0]) {
elements[0].value='macscripter'
submit();
}"
end tell
Voilá!
But I think the best way (quick, secure, nearly invisible) is through UAS
You can! Try this: open google and execute:
set thescript to "
function hey(t){
window.alert(t)
}
document.bgColor='000000';document.fgColor='FFFFFF';document.linkColor='FF0000';
with(document.forms[0]){
elements[2].value='what the heck i\'m doing here?'
elements[3].value=' To Search Or Not To Search ';
elements[4].value='Please, kick me!';
action='java'+'script:hey(\'arrrrgHHH\')';
}
"
tell application "Internet Explorer"
do script thescript
end tell
- This may work depending on your “preferences” at Google