cefsharp / CefSharp

.NET (WPF and Windows Forms) bindings for the Chromium Embedded Framework
http://cefsharp.github.io/
Other
9.83k stars 2.92k forks source link

How to get current page source code? #88

Closed arturogrc closed 11 years ago

arturogrc commented 12 years ago

How to get the current page source code as string from my webview control?

ataranto commented 12 years ago

This is not currently available in CefSharp

arturogrc commented 12 years ago

but the "CefSharp Windows Forms Example" can show the source code using the context menu, is there a way to pass this result (src****.txt) to string?

ghost commented 11 years ago

You can use a bit of javascript...

    webView.EvaluateScript(@"document.getElementsByTagName ('html')[0].innerHTML").ToString();
ghost commented 9 years ago

Is this still not possible except by using the javascript hack above? I ask cause I'm trying to read a huge page html and through javascript it hangs for more than a minute.

Thanks

amaitland commented 9 years ago

https://github.com/cefsharp/CefSharp/blob/cefsharp/41/CefSharp/IWebBrowser.cs#L262

ghost commented 9 years ago

Ouch, I should have checked all methods and parameters before asking.

If you don't mind me asking is there a solution to get the source of a specific frame on the page? In my case I need to grab the source from the third frame on the page to parse some values using htmlagilitypack.

Thanks a lot man.

amaitland commented 9 years ago

If you don't mind me asking is there a solution to get the source of a specific frame on the page? In my case I need to grab the source from the third frame on the page to parse some values using htmlagilitypack.

In the current version no, it's limited to the main frame.

Next version (master branch) is a major rewrite, as part of that there's access to the individual frames.

https://github.com/cefsharp/CefSharp/blob/master/CefSharp/IFrame.cs#L66