Home > Net >  Traverse elements CEF3 how to obtain the document interface
Traverse elements CEF3 how to obtain the document interface

Time:09-22

http://blog.csdn.net/foruok/article/details/50799518
MFC to embed a Google browser kernel, now need to get the document interface, used to traverse the web page elements, is not the way to js, is directly to c + + code.
According to the above method of post, has realized the CefDOMVisitor class
The class DomVisitTestor: public CefDOMVisitor
{
Public:
DomVisitTestor ();
Void TestAccess (CefRefPtr The document);
Void TestModify (CefRefPtr The document);

Void Visit (CefRefPtr OVERRIDE the document);

IMPLEMENT_REFCOUNTING (DomVisitTestor);
};

And implement the
M_clientHandler - & gt; GetBrowser () - & gt; GetMainFrame () - & gt; VisitDOM (new ClientDOMVisitor ());

But DomVisitTestor: : Visit (); Never be executed.

Don't have a clue, hope the great god gave advice, in order to traverse the web page elements, not with js method.

CodePudding user response:

Please find a way?

CodePudding user response:

It is said that need to render the main thread calls the method

CodePudding user response:

Do you find a solution now

CodePudding user response:

Is there a DEMO!

CodePudding user response:

Find a p, var STM=chromeBrowser GetSourceAsync (). The Result; Only in this way, analysis of this string

CodePudding user response:

I am sending a message in the app, call in the render, is ok,

CodePudding user response:

HtmlAgilityPack. The HtmlDocument doc=new HtmlAgilityPack. The HtmlDocument ();
Doc. LoadHtml (Html);//to add source page
HtmlNode HtmlNode=doc. DocumentNode. SelectSingleNode ("//div [@ class='results'] ");//access web node
HtmlAgilityPack. HtmlNodeCollection nodecollection=htmlnode..childnodes;
for (int i=0; i {
The string result=nodecollection [I] OuterHtml;//traverse the nodes to get to want to be the source of
}

Don't know whether you need these, I this is a c #, hope to be able to help
  • Related