我正在尝试一次在浏览器中加载一个URL列表。我不关心任何输出,我只需要加载页面,一旦完成加载,将位置更改为列表中的下一个URL。我已尝试并放弃在Automator中完成此操作。我使用CURL,但我不太了解传递身份验证(必须存在几个cookie)。
这可以通过简单的ActionScript实现吗?理想情况下,输入将是一个txt文件,每个URL都有一行。
更新!这是有效的:
set thePath to (path to desktop as Unicode text) & "sites.txt"
set theFile to (open for access file thePath)
set theContent to (read theFile)
close access theFile
set theURLs to every paragraph of theContent
tell application "Safari"
repeat with theURL in theURLs
make new document
set URL of front document to theURL
delay 1
repeat until ((do JavaScript "document.readyState" in front document) is "complete")
delay 1
end repeat
close front document
end repeat
end tell
答案 0 :(得分:3)
这将设置URL列表,加载每个URL,并等待文档准备好继续。请注意,每个网址都必须完整(即http://cnn.com/
而不是cnn.com
)才能以这种方式加载网页。
set myURLs to {"http://stackoverflow.com/", "http://cnn.com/", "http://nytimes.com/"}
tell application "Safari"
make new document
set myDoc to front document
repeat with myURL in myURLs
set URL of myDoc to myURL
-- wait until page is loaded to open new page
repeat until ((do JavaScript "document.readyState" in front document) is "complete")
delay 1
end repeat
end repeat
end tell