gpt4 book ai didi

c#无法解析xml,收到错误463

转载 作者:行者123 更新时间:2023-11-30 23:27:56 24 4
gpt4 key购买 nike

基本上我正在尝试解析 xml from this
但是我收到{“远程服务器返回错误:(463)。”}(System.Net.WebException)错误发生在string xml = webClient2.DownloadString(address);

这是我的完整代码

Task.Run((Action)(() =>
{
XmlDocument xmlDocument = new XmlDocument();
using (WebClient webClient1 = new WebClient())
{
WebClient webClient2 = webClient1;
Uri address = new Uri("https://habbo.com/gamedata/furnidata_xml/1");
string xml = webClient2.DownloadString(address);
xmlDocument.LoadXml(xml);
}
foreach (XmlNode xmlNode1 in xmlDocument.GetElementsByTagName("furnitype"))
{
string nr1 = "[" + xmlNode1.Attributes["id"].Value + "]";
string nr2 = " : " + xmlNode1.Attributes["classname"].InnerText;
foreach (XmlNode xmlNode2 in xmlNode1)
{
XmlNode childNode = xmlNode2;
if (childNode.Name == "name")
{
this.FurniCB.Invoke((Action)(() => this.FurniCB.Items.Add((object)(nr1 + nr2 + " : " + childNode.InnerText))));
this.FurniDataList.Add(nr1 + nr2 + " : " + childNode.InnerText);
}
}
}
}));

提前致谢

最佳答案

我测试了你代码的下载部分。您只需要将 User-Agent header 添加到请求中即可。

webClient1.Headers.Add("User-Agent", "Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30");

关于c#无法解析xml,收到错误463,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36238438/

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