macOSでブラウザのURLを取得する方法

Pocket

macOSにはAppleScript(osascript)というスクリプト言語が使えます。そのAppleScriptのコマンドを使えば今開いているブラウザURLを取得することができます。AppleScript利用するには、ターミナルでosascriptコマンドを使います。

SafariのURLを取得するには下記のコードです。

osascript -e 'tell app "safari" to get the url of the current tab of window 1'

Google ChromeのURLを取得する場合

osascript -e 'tell app "google chrome" to get the url of the active tab of window 1'

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA


2022 MJELD TECHNOLOGIES. ALL RIGHTS RESERVED