Like Romasz, use InvokeScriptAsync, but first make sure the page is loaded.
Application example:
<Grid>
<StackPanel>
<WebView x:Name="myWebView" Height="300" VerticalAlignment="Top" />
<Button Content="Read HTML" Click="Button_Click" />
<TextBlock x:Name="myTextBlock"></TextBlock>
</StackPanel>
</Grid>
private void Page_Loaded(object sender, RoutedEventArgs e)
{
this.myWebView.Navigate(new Uri("http://www.google.com", UriKind.Absolute));
}
private async void Button_Click(object sender, RoutedEventArgs e)
{
try
{
string html = await myWebView.InvokeScriptAsync("eval", new string[] { "document.documentElement.outerHTML;" });
myTextBlock.Text = html;
}
catch (Exception ex)
{
}
}

source
share