Received: Invalid URI:主机名不能被解析

本文关键字:不能 主机 Invalid URI Received | 更新日期: 2023-09-27 18:18:17

所以我用这个来加载一个网站:

WebClient webClient = new WebClient();
            webClient.Encoding = Encoding.UTF8;
            string str2 = webClient.DownloadString(url);
            if (Program.proxies.Count > 0)
            {
                string Address = Program.proxies[new Random().Next(0, Program.proxies.Count)];
                string[] strArray = Address.Split(':');
                if (strArray.Length > 2)
                    webClient.Proxy = (IWebProxy)new WebProxy(strArray[0] + ":" + strArray[1])
                    {
                        Credentials = (ICredentials)new NetworkCredential(strArray[2], strArray[3])
                    };
                else
                    webClient.Proxy = (IWebProxy)new WebProxy(Address);
            }
            return str2.Replace("'", "'");
        }
        catch (Exception ex1)
        {
            try
            {
                using (StreamWriter streamWriter = System.IO.File.AppendText("log.txt"))
                    streamWriter.WriteLine("[" + DateTime.Now.ToString() + "] " + ex1.Message);
                str1 = "";
            }
            catch (Exception ex2)
            {
                str1 = "";
            }
        }

和我得到无效的URI:主机名无法在日志中解析,过去的工作,我添加了一个windows窗体,现在我不能让它像以前一样工作…就像一个哑巴…我删除了我的旧项目

Received: Invalid URI:主机名不能被解析

我发现是我的代理列表文件中有一个空格