C# Convert Relative to Absolute Links in HTML String

前端 未结 10 1674
余生分开走
余生分开走 2020-12-16 04:03

I\'m mirroring some internal websites for backup purposes. As of right now I basically use this c# code:

System.Net.WebClient client = new System.Net.WebCli         


        
10条回答
  •  被撕碎了的回忆
    2020-12-16 04:41

    I think url is of type string. Use Uri instead with a base uri pointing to your domain:

    Uri baseUri = new Uri("http://domain.is");
    Uri myUri = new Uri(baseUri, url);
    
    System.Net.WebClient client = new System.Net.WebClient();
    byte[] dl = client.DownloadData(myUri);
    

提交回复
热议问题