我在谷歌小组中提出了问题,他们告诉我实现'CefStringVisitor‘类,我照做了。
namespace Xilium.CefGlue.WPF.Customer
{
class MyCefStringVisitor : CefStringVisitor
{
private string html;
protected override void Visit(string value)
{
html = value;
}
public string Html
{
get { return html; }
set { html = value; }
}
}
}但我收到的是文本word,而不是HTML资源。
如何获取HTML源代码?
发布于 2015-03-25 21:41:34
尝尝这个
private sealed class SourceVisitor : CefStringVisitor
{
private readonly Action<string> _callback;
public SourceVisitor(Action<string> callback)
{
_callback = callback;
}
protected override void Visit(string value)
{
_callback(value);
}
}
protected override void OnLoadEnd(CefBrowser browser, CefFrame frame, int httpStatusCode)
{
if (frame.IsMain)
{
string HtmlSourceCode;
var visitor = new SourceVisitor(text =>
{
BeginInvoke(new Action(() =>
{
HtmlSourceCode = text;
}));
});
frame.GetSource(visitor);
}
}https://stackoverflow.com/questions/18372755
复制相似问题