【问题标题】:Received : Invalid URI : The hostname could not be parsed收到:无效的 URI:无法解析主机名
【发布时间】:2023-03-09 12:58:01
【问题描述】:

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

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 窗体,现在我不能让它像以前那样工作......而且像个笨蛋。 .. 我删除了我的旧项目

【问题讨论】:

  • 什么是Program.proxiesurl 是什么?

标签: c# web uri invalidation


【解决方案1】:

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

【讨论】:

  • 如果您找到答案,请将此标记为问题的答案,以便其他可能有此问题的人有答案。
猜你喜欢
  • 2011-05-11
  • 2011-02-18
  • 2016-01-28
  • 1970-01-01
  • 2017-08-04
  • 2015-06-03
  • 2023-03-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多