开发者

Determine current Mac Safari web page using Python

开发者 https://www.devze.com 2022-12-21 19:05 出处:网络
Is there a way to determine programmatically, using Pytho开发者_StackOverflow社区n, which web page is currently active in Safari?An Applescript example is here, and the relevant part is:

Is there a way to determine programmatically, using Pytho开发者_StackOverflow社区n, which web page is currently active in Safari?


An Applescript example is here, and the relevant part is:

tell application "Safari"
    set url_list to URL of every document
end tell

Python/AppleScript translation is covered here. E.g., install appscript as described here:

sudo easy_install appscript

and then, as shown here, you can do e.g.:

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号