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
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
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!
|
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
|