Applescript:重复直到reCaptcha发生

时间:2016-03-26 11:49:33

标签: applescript recaptcha repeat

我在编码方面很陌生,尤其是使用AppleScript。我设法使以下代码工作:

tell application "Safari"

    repeat
        delay 7.5
        set the URL of document 1 to "https://url.com"
        delay 2
        tell document 1
            do JavaScript "document.getElementById(\"id1\").click()"
            do JavaScript "document.getElementById(\"id2\").click()"
            do JavaScript "document.getElementById(\"id3\").click()"
            do JavaScript "document.getElementById(\"id4\").click()"
            do JavaScript "document.getElementById(\"id5\").click()"
            do JavaScript "document.getElementById(\"id6\").click()"
            delay 0.25
        end tell
        tell application "Safari"
            activate
        end tell

        tell application "System Events"
            delay 0.25
            tell process "Safari" to key code 48
            delay 0.5
            key code 21

        end tell

        delay 0.25

        tell application "Safari"

            tell document 1
                do JavaScript "document.getElementById(\"book\").click()"

            end tell
        end tell
    end repeat

end tell

我不想一直重复代码,而是要重复代码,直到Google reCaptcha发生,并在最后一次javascript操作后弹出。

1 个答案:

答案 0 :(得分:1)

我的建议是重新构建你的重复声明......

set done to false
repeat while not done

    if reCaptcha = "something" then
        set done to true
    end if
end repeat