当前位置:首页 > 操作系统 > MacOs

使用Python确定当前的Mac Safari网页

有没有办法以编程方式确定,使用Python,哪个网页目前在Safari中处于活动状态?

解决方法:

Applescript示例是here,相关部分是:

<code>tell application "Safari"
    set url_list to URL of every document
end tell
</code>

Python / AppleScript翻译包含在here.例如,按照here所述安装appscript:

<code>sudo easy_install appscript
</code>

然后,如图here所示,你可以做例如:

<code>>>> import appscript
>>> print appscript.app("Safari").windows.first.current_tab.URL()
http://wiki.python.org/moin/MacPython/Safari
</code>

【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!

相关教程推荐

其他课程推荐