Welcome Guest Search | Active Topics | Sign In | Register

Extraction of HTML tag content from WebView.GETHTML (VB.NET) Options
Prequena84
Posted: Wednesday, June 16, 2021 12:41:52 PM
Rank: Advanced Member
Groups: Member

Joined: 5/10/2021
Posts: 43
hello good morning, I am currently carrying out a project for a client on the inventory load of a website has an excel using VB.NET, through its technology, and I am currently passing the content obtained from GETHTML to an HTLM.document ( Webbrowser) to get GETHTML as HTLM.Document and with a For Each read the tags, but this takes me a long time so I have to wait for the webbrowser to load and sometimes it does not extract the data correctly.

I was doing some tests with your material and this is what I managed to extract directly:

sample website tag:

<input type = "hidden" id = "ProductInfoPrice_22854" value = "$ 229.00" autocomplete = "off">


my code for the extraction of a price:


Dim Nav As EO.WebBrowser.DOM.Window = WebView2.GetDOMWindow ()
Dim Document As EO.WebBrowser.DOM.Document = Nav.document
Dim Value As EO.WebBrowser.DOM.Element = Document.getElementById ("ProductInfoPrice_22854")


'Obtaining Value = price ($ 299.00)

Dim Test1 As String
Test1 = Value.Item ("value")


In the label that have a unique ID it can work for me, but my problem is that I try to do it by locating the classes of the label and this logic does not work because they are dynamic labels and for the customer's inventory effect it varies for each article and this is the problem I have using this technology


eo_support
Posted: Wednesday, June 16, 2021 1:30:03 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Hi,

You should do this with JavaScript instead. We only exposed very few DOM interface. However with JavaScript you can do almost anything. Your code can be something like this. The JavaScript code can be something like this:

Code: Visual Basic.NET
Dim jsCode As String = "(function ()
{
  var input = document.getElementById('ProductInfoPrice_22854');
  return input.value;
})();"
Dim value As String = CStr(webView.EvalScript(jsCode))


You would change the JavaScript code inside the anonymous function to perform any logic you would like.

Thanks!
Prequena84
Posted: Wednesday, June 16, 2021 1:36:21 PM
Rank: Advanced Member
Groups: Member

Joined: 5/10/2021
Posts: 43
Thank you so much, I'm going to try it since I must see how I extract the dynamic classnames from the Web


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.