2013-08-22 4 views
1

Google 그룹에서 질문을 제기했으며, 그들은 'CefStringVisitor'클래스를 구현하라고 말했습니다.CefGlue HTML 소스를 얻는 방법?

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; } 
     } 
    } 
} 

그러나 HTML 문자 대신 텍스트 단어가 나타납니다.

어떻게하면 HTML 소스를 얻을 수 있습니까?

답변

0

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); 
     } 
} 
시도
관련 문제