【问题标题】:How can I open a site in web browser from command line?如何从命令行在 Web 浏览器中打开网站?
【发布时间】:2022-06-24 19:37:04
【问题描述】:

我只想能够通过 curl 命令打开一个网站。我还没有找到任何相关的东西。弹出的所有结果主要针对移动应用程序及其各自的开发语言。我希望能够做到:

curl <some flag or option> google.com

然后会弹出 google.com 网页。这样的事情可能吗?

【问题讨论】:

  • 是不是因为需要下载.html文件,然后打开?或者它可以直接在默认浏览器中打开您的 URL?例如。这应该适用于 ubuntu:curl URL &gt; file.html &amp;&amp; xdg-open file.html 或直接xdg-open URL
  • @Jeppe 是的,第二部分。主要是想直接在浏览器中打开,但不想下载文件。我会尝试这两种方式,看看它是否对我的用例有帮助。
  • @Jeppe 是的,它奏效了!谢谢!我做了xdg-open URL,它在我的默认网络浏览器中正确打开了该网站。
  • 好的,但是您的问题与curl 并没有真正的关系。您应该更新问题以反映这一点。
  • 好的,刚刚做了。感谢您的帮助!

标签: ubuntu curl


【解决方案1】:

让我们收集一下默认浏览器打开 URL 的各种方式:

Ubuntu

sensible-browser google.com 或者 xdg-open google.com.

这里也有回答: https://askubuntu.com/questions/8252/how-to-launch-default-web-browser-from-the-terminal

Windows

start chrome https://www.google.com/start firefox https://www.google.com/

在这里回答:https://stackoverflow.com/a/32775952/3717691

MacOS

open "google.com"

在这里回答:https://stackoverflow.com/a/23039509/3717691

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-04
    • 1970-01-01
    • 2015-05-10
    • 2011-05-09
    • 1970-01-01
    • 2012-08-11
    • 2016-09-02
    • 2012-12-23
    相关资源
    最近更新 更多