how to extract inner/outer text from webview2 ?

RAFOO

New member
Joined
Jun 6, 2024
Messages
4
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.
 

Latest posts

Back
Top