【发布时间】:2017-12-01 10:37:25
【问题描述】:
我在 httpwebresponse 中得到纯 json 响应,但无法在 htmldoc 或其他中得到它...
这里是代码..
public HtmlDocument Load(string url, string method)
{
Uri uri = new Uri(url);
HtmlDocument doc;
if ((uri.Scheme == Uri.UriSchemeHttps) ||
(uri.Scheme == Uri.UriSchemeHttp))
{
doc = LoadUrl(uri, method, null, null);
}
else
{
if (uri.Scheme == Uri.UriSchemeFile)
{
doc = new HtmlDocument();
doc.OptionAutoCloseOnEnd = false;
doc.OptionAutoCloseOnEnd = true;
if (OverrideEncoding != null)
doc.Load(url, OverrideEncoding);
else
doc.DetectEncodingAndLoad(url, _autoDetectEncoding);
}
else
{
throw new HtmlWebException("Unsupported uri scheme: '" + uri.Scheme + "'.");
}
}
if (PreHandleDocument != null)
{
PreHandleDocument(doc);
}
return doc;
}
谁能告诉我如何从 httpwebresponse 获取文档上相同的 json 文本..
【问题讨论】:
-
Json 不是 Html。如果响应是json,那你为什么要使用HtmlAgilityPack?
标签: c# html-agility-pack