Search code examples
c#windows-8webviewwindows-runtimewindows-8.1

Extract html content of webview in Windows 8


Is there any way to extract html of currently displayed page in webview? I need to extract html and parse and reload again? I tried Htmlclienthandler which works ok if it is simple website

HttpClientHandler handler = new HttpClientHandler { UseDefaultCredentials = true,       AllowAutoRedirect = true };

HttpClient client = new HttpClient(handler);
HttpResponseMessage response = await client.GetAsync(url);

But page is in OWA email page and i am keep getting Error:400 Bad requesr in response.


Solution

  • You can extract HTML from WebView using InvokeScript(...) method.

    string html = webview.InvokeScript("eval", new string[] {"document.documentElement.outerHTML;"});