【问题标题】:Get contents of a Safari windows in Applescript在 Applescript 中获取 Safari 窗口的内容
【发布时间】:2011-09-01 19:39:58
【问题描述】:
我想获取 Safari 5.1 (Mac OS X) 网页的内容并使用 Applescript 将其粘贴到另一个应用程序中。
我对 AppleScript 比较熟悉,但对 JavaScript 不熟悉,因为我假设答案在于 JavaScript。
我可以使用系统事件来使用击键来选择全部然后复制...这工作正常,但我有两个问题:
- 这很丑陋,而且肯定有办法以编程方式做到这一点。
- 我做的 Select All 无法撤消,这更难看?
谁能帮忙?
谢谢,尼克。
【问题讨论】:
标签:
javascript
safari
applescript
【解决方案1】:
你可以试试这个……
set the webpage_content to ""
tell application "Safari" to set the webpage_content to the text of document 1
tell application "TextEdit"
activate
set the text of the front document to the webpage_content
end tell