gpt4 book ai didi

c# - 为什么 Dns.GetHostAddresses 无法获取 https ://google. com 的 IP 地址?

转载 作者:行者123 更新时间:2023-11-30 13:44:16 26 4
gpt4 key购买 nike

我正在尝试使用以下代码获取“https://google.com”的主机地址:

 var host = Dns.GetHostAddresses("https://google.com");

但我得到一个异常(exception):

{"No such host is known"}

我想知道,为什么我无法获取条目?

最佳答案

不要提供 https://,只需提供 google.com,因为 https:// 不是主机名的一部分。

 var host = Dns.GetHostAddresses("google.com");

我发现对 URL 部分的解释非常好 here摘录如下。

http://video.google.co.uk:80/videoplay?docid=-7246927612831078230&hl=en#00h02m30s

以下是 url 的一些组成部分:

  • The protocol is http. Other protocols include https, ftp, etc.
  • The host or hostname is video.google.co.uk.
  • The subdomain is video.
  • The domain name is google.co.uk.
  • The top-level domain or TLD is uk. The uk domain is also referred to as a country-code top-level domain or ccTLD. For google.com, the TLD would be com.
  • The second-level domain (SLD) is co.uk.
  • The port is 80, which is the default port for web servers. Other ports are possible; a web server can listen on port 8000, for example. When the port is 80, most people leave out the port.
  • The path is /videoplay. Path typically refers to a file or location on the web server, e.g. /directory/file.html
  • This URL has parameters. The name of one parameter is docid and the value of that parameter is -7246927612831078230. URLs can have lots parameters. Parameters start with a question mark (?) and are separated with an ampersand (&). See the “#00h02m30s”? That’s called a fragment or a named anchor. The Googlers I’ve talked to are split right down the middle on which way to refer it. Disputes on what to call it can be settled with arm wrestling, dance-offs, or drinking contests. 🙂 Typically the fragment is used to refer to an internal section within a web document. In this case, the named anchor means “skip to 2 minutes and 30 seconds into the video.” I think right now Google standardizes urls by removing any fragments from the url.

关于c# - 为什么 Dns.GetHostAddresses 无法获取 https ://google. com 的 IP 地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42693106/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com