Hi guys,
i've got a problem with a scraping of a table from a website. Unfortunally i don't have an id to locate in a second the table in the web page, but this is located in another table that i can identify. I can post the html code here below :
What i need to read are the value in the nested table inside the main one, the table where are placed the value : 1.42,1.43,1.68,1.72,1.73.
I can read the table with id "addreg", but cant "navigate" in the nested table.
I've read the first table with the following code :
Can someone help me with this problem?There is a procedure to parse a table from html also if i don't have any id/class to identify?
Is possible to navigate the chield of the table and read the table inside a child?
Thanks a lot in advance!!!
i've got a problem with a scraping of a table from a website. Unfortunally i don't have an id to locate in a second the table in the web page, but this is located in another table that i can identify. I can post the html code here below :
Code:
< table id="addreg" class="display dataTable" cellspacing="0" style="width: 98%;" summary="Dettaglio procedimenti" role="grid" aria-describedby="addreg_info">
< thead>
< tr role="row">
< th class="sorting_desc" tabindex="0" aria-controls="addreg" rowspan="1" colspan="1" aria-label=" Data pubblicazione : activate to sort column ascending" aria-sort="descending" style="width: 127px;"> Data pubblicazione < /th>
< th class="details-control sorting_disabled" rowspan="1" colspan="1" aria-label=" Dati di dettaglio (Aliquote/Fasce applicazione/Disposizioni particolari/Norme di riferimento/Note)" style="width: 628px;"> Dati di dettaglio (Aliquote/Fasce applicazione/Disposizioni particolari/Norme di riferimento/Note)< /th>
< /tr>
< /thead>
< tfoot>
< tr>
< th rowspan="1" colspan="1"> Data pubblicazione < /th>
< th class="details-control" rowspan="1" colspan="1"> Dati di dettaglio (Aliquote/Fasce applicazione/Disposizioni particolari/Norme di riferimento/Note)< /th>
< /tr>
< /tfoot>
< tbody>
< tr role="row" class="odd shown">
< td class="sorting_1">23-GEN-18< /td>
< td class=" details-control">< /td>
< /tr>
< tr>
< td colspan="2">
< table cellpadding="5" cellspacing="0" border="0" width="98%">
< tbody>
< tr style="width:50px;">
< th style="text-align:right;">Aliquota< /th>
< th>Fascia di applicazione< /th>
< /tr>
< tr>
< td align="right">1.42
< hr>1.43
< hr>1.68
< hr>1.72
< hr>1.73< /td>
< td>fino a 15000.00 euro
< hr>oltre 15000.00 e fino a 28000.00 euro
< hr>oltre 28000.00 e fino a 55000.00 euro
< hr>oltre 55000.00 e fino a 75000.00 euro
< hr>oltre 75000.00 euro< /td>
< /tr>
< /tbody>
< /table>
< table cellpadding="5" cellspacing="0" border="0" width="98% style=" padding-left:100px; "=" ">< tbody>< tr>< th>Disposizioni particolari< /th>< /tr>< tr>< td> < /td>< /tr>< tr>< th>Norme di riferimento< /th>< /tr>< tr>< td>ART.4 L.R. 77/2012< /td>< /tr>< tr>< th>Note< /th>< /tr>< tr>< td> < /td>< /tr>< /tbody>< /table>< /td>< /tr>< /tbody>
< /table>
What i need to read are the value in the nested table inside the main one, the table where are placed the value : 1.42,1.43,1.68,1.72,1.73.
I can read the table with id "addreg", but cant "navigate" in the nested table.
I've read the first table with the following code :
Code:
Sub test()
Dim IE As New SHDocVw.InternetExplorer
Dim HTMLdoc As MSHTML.HTMLDocument
Dim HTMLTable As MSHTML.IHTMLElement
Dim HTMLTables As MSHTML.IHTMLElementCollection
Dim HTMLRow As MSHTML.IHTMLElement
Dim HTMLCell As MSHTML.IHTMLElement
IE.Visible = False
IE.navigate "http://www1.finanze.gov.it/finanze2/dipartimentopolitichefiscali/fiscalitalocale/addregirpef/addregirpef.php?reg=17&anno=2018"
'Do While IE.Busy = True Or IE.readyState <> 4: DoEvents: Loop
' Do While IE.readyState <> READYSTATE_COMPLETE
' Loop
Application.Wait (Now + TimeValue("0:00:2"))
Set HTMLdoc = IE.document
Set HTMLTables = HTMLdoc.getElementsByTagName("table")
'Debug.Print HTMLTables.Length
For Each HTMLTable In HTMLTables
'Debug.Print HTMLTable.className
For Each HTMLRow In HTMLTable.getElementsByTagName("tr")
'Debug.Print vbTab & HTMLRow.innerText
For Each HTMLCell In HTMLRow.getElementsByTagName("td")
Debug.Print vbTab & HTMLCell.innerText
Next HTMLCell
Next HTMLRow
Next HTMLTable
'Debug.Print HTMLTables(0).getElementsByTagName("tr").innerText
IE.Quit
End Sub
Can someone help me with this problem?There is a procedure to parse a table from html also if i don't have any id/class to identify?
Is possible to navigate the chield of the table and read the table inside a child?
Thanks a lot in advance!!!