使用 Appcelerator 在 mac 上获取 safari 和 chrome 打开的选项卡
我需要读取 Safari、Chrome 和 Firefox 中打开的选项卡 URL(可选)并将它们转换为数组。 我正在使用 Titanium Appcelerator 开发桌面应用程序,它支持 Python。
也可以通过调用返回我正在寻找的内容的 AppleScript 来完成。 例如,这个简单的 AppleScript 显示了我正在寻找的内容
tell application "Safari"
get URL of every tab of every window
end tell
现在我如何从 Python 或 JavaScript 调用它(我不知道 JavaScript 是否可以)?
有人有个好主意吗? 谢谢你!
I need to read opened tabs URL in Safari, Chrome and Firefox (optionally) and turn them into an array.
I'm using Titanium Appcelerator to develop a Dektop Application, and it support Python.
It can be also done by calling an AppleScript that return what I'm looking for.
For example this simple AppleScript show what I'm looking for
tell application "Safari"
get URL of every tab of every window
end tell
Now how I can call this from Python or JavaScript (I don't know if it's possible with JavaScript) ?
Someone have a great idea?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有两种方法可以通过 python 执行此操作...
1.(我的偏好)安装 appscript:
pip install appscript
2.Shell 到命令行并调用 osascript:
There are two ways you can do this via python...
1.(My preference) Install appscript:
pip install appscript
2.Shell out to the commandline and call osascript:
你可以像这样将 AppleScript 嵌入到 python 脚本中,
我希望这会有所帮助!
You can just embed the AppleScript in a python script like so
I hope this helps!