Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

zbotnik

macrumors newbie
Original poster
Aug 10, 2010
5
0
Hi all,

I have an applescript that does what it's supposed to do. It first logs in to a website in one window, then after 3s delay performs another action in a new window. It works.

Although, since loading times can vary, my script might be too fast (and yes, it needs to be as fast as possible). 3 second delays to wait for the page to load is normally enough, but sometimes it's not, in which case everything goes wrong. Using keystrokes, so they would end up in the wrong boxes and so on.

I also don't want to wait for the whole page to load, since there are photos that can take forever, causing a real, unnecessary delay.

Now, I'd like a piece of script that can look for the text "Xxxxxx" on the confirmation page that loads after this second action.
If "Xxxxx" is not found, I'd like the script to be run again. If the text is in fact found, all is well.

Using Safari.

Grateful for any suggestions!
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
This is always my suggestion, because I don't know applescript very well, but would it be possible to do the heavy lifting as a shell script? I don't know how complex the transition between pages is, but it is likely possible to do what you need with curl. This also fixes the image loading issue, because curl is only going to grab the html of the page, so it should be much faster.

If you post the URL(s) you're working with we might be able to help more.

-Lee
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,852
9
USA
A script that auto-logins then then grabs a confirmation code. Sounds like what some hackers use to automate account creation for spamming.

Anyways, have the script disable images in Safari so it doesn't have to wait for them to download. Then the script can also check if the page is done downloading rather than waiting a specific amount of time.
 

mrbash

macrumors 6502
Aug 10, 2008
251
1
If you know the log-in information beforehand, you do not need to wait for the page to load. Why not directly send the POST/GET request to login?

Store the login form's action parameters, and construct a URL with the appropriate attributes. I'm assuming that there is no client side processing that occurs on the login page and that there is no server token you have to pass along with the request.
 

zbotnik

macrumors newbie
Original poster
Aug 10, 2010
5
0
If you know the log-in information beforehand, you do not need to wait for the page to load. Why not directly send the POST/GET request to login?

Store the login form's action parameters, and construct a URL with the appropriate attributes. I'm assuming that there is no client side processing that occurs on the login page and that there is no server token you have to pass along with the request.

Well, this is the login page: https://bokabostad.stockholm.se/LoggaIn.aspx

I've tried to create the URL you mention, but unsuccessfully. Can I just look at the source code, or do I need to fetch something else?
 

mrbash

macrumors 6502
Aug 10, 2008
251
1
I saw the page and there may be some client side JS that transforms the input, also there were a few hidden input fields that seemed to have some generated values. I suspect that what I described will not work, although it is worth trying to construct a GET request with the parameters.

Lee's suggestion of using curl is probably your best bet but the server may reject your login attempt if you don't maintain the same session.

I was able to locate some AppleScript that loops till Safari has finished loading a page. You may want to try that instead. link to macosxhints.com
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.