有一个有一堆链接的网页。
所有这些链接都将使用javascript的onclick函数。
每个链接都有参数,这些参数将被用来决定登录页面。
在这种情况下,如果链接总是具有相同的关键字,我如何编写applescript来跳转到特定页面。
我正在使用脚本编辑器在MaxOS Lion上使用Safari自动执行此操作。
发布于 2012-10-12 19:14:34
我认为Chrome对Javascript命令的响应更好。
set myKeyword to "questions"
tell application "Google Chrome"
tell window 1 to tell active tab
set URL to "http://stackoverflow.com/"
delay 3
set num_links to (execute javascript "document.links.length") - 1
repeat with i from 0 to num_links
set myLink to execute javascript "document.links[" & i & "].href"
if myLink contains myKeyword then
execute javascript "document.links[" & i & "].click()"
end if
end repeat
end tell
end tellhttps://stackoverflow.com/questions/12852707
复制相似问题