You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Bash中获取Edge浏览器当前活动标签页的URL与标题?

在Bash环境下获取Edge浏览器当前活动标签页的URL及标题

Edge没有官方提供类似Chrome的chrome-cli工具,不过可以通过以下平台特定的方法实现:

macOS 平台

利用AppleScript结合osascript命令直接调用Edge的脚本接口,模拟chrome-cli info的输出格式:

osascript -e 'tell application "Microsoft Edge"
    set activeTab to active tab of front window
    return "Id: " & id of activeTab & linefeed & "Window id: " & id of front window & linefeed & "Title: " & title of activeTab & linefeed & "Url: " & URL of activeTab & linefeed & "Loading: " & (loading of activeTab as string)
end tell'

执行后输出示例:

Id: 123456789
Window id: 987654321
Title: GPT-4 - Poe
Url: https://poe.com/GPT-4
Loading: false

如果只需要简洁的URL和标题,可使用简化版命令:

osascript -e 'tell application "Microsoft Edge" to get {URL, title} of active tab of front window'

Linux 平台

通过Edge的远程调试接口配合curl和jq工具实现:

  1. 确保Edge已启动并开启远程调试(首次执行需启动Edge):
microsoft-edge --remote-debugging-port=9222 &
  1. 调用调试接口获取活动标签信息:
curl -s http://localhost:9222/json | jq -r '.[] | select(.active == true) | "Id: \(.id)\nWindow id: \(.windowId)\nTitle: \(.title)\nUrl: \(.url)\nLoading: \(.loading | tostring)"'

注:需提前安装jq工具(Debian/Ubuntu可通过sudo apt install jq安装)。

内容的提问来源于stack exchange,提问作者HappyFace

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 16:02:10