Using System.Net.WebRequest with a known IP end point

前端 未结 1 1097
遥遥无期
遥遥无期 2021-01-25 06:25

I have a large collection of DNS names that have already been resolved to IP addresses. With this collection I need to download HTML from them. It\'s a very large list and I nee

相关标签:
1条回答
  • 2021-01-25 06:48

    Pretty simple:

    var ip = "93.184.216.119";
    var host = "example.com";
    var ipUri = new UriBuilder(Uri.UriSchemeHttp, ip).Uri;
    
    var request = WebRequest.CreateHttp(ipUri);
    request.Host = host;
    
    using (var response = request.GetResponse())
    {
        // do something with response
    }
    
    0 讨论(0)
提交回复
热议问题