how to extract inner/outer text from webview2 ?

RAFOO

Member
Joined
Jun 6, 2024
Messages
6
Programming Experience
10+
I am using WebView2 to access websites that are 1st Column of DataGrtidView No Problem at all. But now I need to extract the text (innertext / outerHtml) from webview2 .

Any Help pls?

....
TxtURL.Text = DataGridView1.Rows(nr).Cells(0).Value
WebView21.Source = New Uri(TxtURL.Text)
WebView21.Show()
Catch ex As UriFormatException
'MessageBox.Show("FULL URL ex. --> HTTP")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
....

Tnx in advance.
Regards
Rafoo
 
Execute scripts to interact with the web document:
VB.NET:
Dim source = Await WebView21.ExecuteScriptAsync("document.documentElement.outerHTML")
Dim decoded = System.Text.RegularExpressions.Regex.Unescape(source)
 
Execute scripts to interact with the web document:
VB.NET:
Dim source = Await WebView21.ExecuteScriptAsync("document.documentElement.outerHTML")
Dim decoded = System.Text.RegularExpressions.Regex.Unescape(source)

Hi John, thanks for your help.

I tried but "on the first line "Await" gives the following error:

BC37058: 'Await' can only be used within an Async method. Consider marking this method with the 'Async' modifier and changing its return type to Tasks.

Any suggestions

Thanks once again.
Rafoo
 
Yes, you must add Async to your method. If it's an event handler Sub-method you don't add return type.
 
I was all around with coding, that I read your message and forgot to Thank You. Better Late than Never.

Sorry.
 
Back
Top