Results 1 to 10 of 10

Thread: get data from html table

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    get data from html table

    based the link:

    https://www.codiceinverso.it/elenco-...catastali.html

    i need to click on each city and get the list.

    for example click on Agrigento and get:

    Comune Codice Catastale
    AGRIGENTO A089
    ALESSANDRIA DELLA ROCCA A181
    ARAGONA A351
    BIVONA A896
    BURGIO B275
    CALAMONACI B377
    CALTABELLOTTA B427
    CAMASTRA B460
    CAMMARATA B486
    CAMPOBELLO DI LICATA B520
    CANICATTI' B602
    CASTELTERMINI C275
    CASTROFILIPPO C341
    CATTOLICA ERACLEA C356
    CIANCIANA C668
    COMITINI C928
    FAVARA D514
    GROTTE E209
    JOPPOLO GIANCAXIO E390
    LAMPEDUSA E LINOSA E431
    LICATA E573
    LUCCA SICULA E714
    MENFI F126
    MONTALLEGRO F414
    MONTEVAGO F655
    NARO F845
    PALMA DI MONTECHIARO G282
    PORTO EMPEDOCLE F299
    RACALMUTO H148
    RAFFADALI H159
    RAVANUSA H194
    REALMONTE H205
    RIBERA H269
    SAMBUCA DI SICILIA H743
    SAN BIAGIO PLATANI H778
    SAN GIOVANNI GEMINI H914
    SANTA ELISABETTA I185
    SANTA MARGHERITA DI BELICE I224
    SANT'ANGELO MUXARO I290
    SANTO STEFANO QUISQUINA I356
    SCIACCA I533
    SICULIANA I723
    VILLAFRANCA SICULA L944

    before to click on Agrigento get Agrigento and the part in ( ), in this case Agrigento - AG

    tks for the "hero"!

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,871

    Re: get data from html table

    What have you done so far?

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: get data from html table

    Looks illegal to scrape:

    All the contents of this site including without limitation the texts, databases, lists, images, graphics and more are the property of Nomix srl.

    The reproduction of the materials contained within the site, by any analog or digital means, is not allowed without the written consent of CodiceInverso.it. Copying and / or printing is permitted for personal and non-commercial use only.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    Re: get data from html table

    Quote Originally Posted by Arnoutdv View Post
    What have you done so far?
    Code:
    Sub test()
    
    Dim oDom As Object: Set oDom = CreateObject("htmlFile")
    Dim x As Long, y As Long
    Dim oRow As Object, oCell As Object
    Dim data
    
    y = 1: x = 1
    
    With CreateObject("msxml2.xmlhttp")
    
        .Open "GET", "https://www.codiceinverso.it/elenco-codici-catastali.html", False
        .Send
        oDom.body.innerHtml = .responseText
    End With
    
    With oDom.getElementsByTagName("table")(0)
        ReDim data(1 To .Rows.Length, 1 To .Rows(1).Cells.Length)
        For Each oRow In .Rows
            For Each oCell In oRow.Cells
                data(x, y) = oCell.innerText
                y = y + 1
            Next oCell
            y = 1
            x = x + 1
        Next oRow
    End With
    
    Sheets(1).Cells(1, 1).Resize(UBound(data), UBound(data, 2)).Value = data
    
    End Sub
    my old code:-( pooer

  5. #5
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,871

    Re: get data from html table

    But does it work??
    What do you expect from us?

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    Re: get data from html table

    Quote Originally Posted by Arnoutdv View Post
    But does it work??
    What do you expect from us?
    I dont know the part of code to click on each city and get the related list...

  7. #7
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,414

    Re: get data from html table

    That's Excel-VBA (see that "Sheets(1).Cells-Thingy?)
    IIRC, each Cell on a Worksheet has a Hyperlink-Property and an Event FollowHyperlink
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  8. #8
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: get data from html table

    Quote Originally Posted by Zvoni View Post
    That's Excel-VBA (see that "Sheets(1).Cells-Thingy?)
    IIRC, each Cell on a Worksheet has a Hyperlink-Property and an Event FollowHyperlink
    He's scraping a website and putting it into an Excel spreadsheet.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9
    Addicted Member jj2007's Avatar
    Join Date
    Dec 2015
    Posts
    205

    Re: get data from html table

    Quote Originally Posted by luca90 View Post
    I dont know the part of code to click on each city and get the related list...
    Check the syslink32 control.

  10. #10
    New Member
    Join Date
    Mar 2021
    Location
    California
    Posts
    8

    Re: get data from html table

    <!DOCTYPE html>
    <html>
    <head>
    <title>Read Data from HTML Table uisng JavaScript</title>
    <style>
    table, th, td
    {
    border: solid 1px #DDD;
    border-collapse: collapse;
    padding: 2px 3px;
    text-align: center;
    }
    th {
    font-weight:bold;
    }
    </style>
    </head>
    <body>
    <table id="empTable">
    <tr>
    <th>ID</th>
    <th>Employee Name</th>
    <th>Age</th>
    </tr>
    <tr>
    <td>01</td>
    <td>Alpha</td>
    <td>37</td>
    </tr>
    <tr>
    <td>02</td>
    <td>Bravo</td>
    <td>29</td>
    </tr>
    </table>

    <p><input type="button" id="bt" value="Show Table Data" onclick="showTableData()" /></p>
    <p id="info"></p>
    </body>

    <script>
    function showTableData() {
    document.getElementById('info').innerHTML = "";
    var myTab = document.getElementById('empTable');

    // LOOP THROUGH EACH ROW OF THE TABLE AFTER HEADER.
    for (i = 1; i < myTab.rows.length; i++) {

    // GET THE CELLS COLLECTION OF THE CURRENT ROW.
    var objCells = myTab.rows.item(i).cells;

    // LOOP THROUGH EACH CELL OF THE CURENT ROW TO READ CELL VALUES.
    for (var j = 0; j < objCells.length; j++) {
    info.innerHTML = info.innerHTML + ' ' + objCells.item(j).innerHTML;
    }
    info.innerHTML = info.innerHTML + '<br />'; // ADD A BREAK (TAG).
    }
    }
    </script>
    </html>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width