【发布时间】:2021-08-25 21:13:51
【问题描述】:
我只想在 Windows 的 Anaconda Powershell 中获取我的 IP 地址的输出。
curl https://ipinfo.io/ip
给我以下内容:
StatusCode : 200
StatusDescription : OK
Content : 22.031.123.456
RawContent : HTTP/...
...
...
...
...
Content-Type: text/html; charset=utf-8
Date: ...
Via:...
Forms : {}
Headers : {[..., *], [...], [...],
[..., ...}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : ...
RawContentLength : ...
如您所见,“内容”显示了我的 IP 地址。但是没有任何其他信息我无法获得 IP 地址。
注意:“curl api.ipify.org”和“curl ipinfo.io/ip”和其他人正在做同样的事情。
【问题讨论】:
-
好吧,
curl只是 Powershell 中Invoke-WebRequest的别名,所以如果您期望其他输出,即来自某些 Windows curl 安装,除非您删除别名,否则您将看不到它在 PowerShell 中。话虽如此,如果您只想要 IP 地址,您可以使用(curl https://ipinfo.io/ip).Content。 -
示例中的内容绝对不是 IP 地址
-
好点,@Ash,但不需要删除别名 - 只需使用
curl.exe调用可执行文件 -
@mklement0 公平点。我仍然忘记了那个,但是当您指定扩展名时,
where.exe之类的东西当然仍然有效。 -
这和 Anaconda 有什么关系? Conda 在启动时添加了一些环境变量,但 PowerShell 仍然是 Microsoft Windows 应用程序。
标签: windows powershell curl anaconda ip-address