Results 1 to 14 of 14

Need help selecting only the first ROW in a Table, Scraped from Web by MSXML2.HTML method!

Threaded View

  1. #1
    Registered User
    Join Date
    03-29-2017
    Location
    Europa
    MS-Off Ver
    2016
    Posts
    7

    Question Need help selecting only the first ROW in a Table, Scraped from Web by MSXML2.HTML method!

    How can i get the children "table" from the parent "table" (the table i'm after is in a bigger table, see below source code) and i want to get only the first row, but excluding a "form" from the Row (it's a href link)

    Untitled.jpg

    And how i can get this continuously (this table is dynamic, it's updating every time some one call me, this first Row, is updating continuously)



    The code below it's geting all the Parent Table and it's taking too long.
    Option Explicit
     'reference to Microsoft Internet Controls
     'reference to Microsoft HTML Object Library
    
    Sub CallLog()
    Dim xml    As Object
    Dim html   As Object
    Dim objTable As Object
    Dim result As String
    Dim lRow As Long
    Dim lngTable As Long
    Dim lngRow As Long
    Dim lngCol As Long
    Dim ActRw As Long
    
    Set xml = CreateObject("MSXML2.XMLHTTP.6.0")
    
    Set html = CreateObject("htmlFile")
    
    With xml
    .Open "POST", "https://www.XXXXXX.xx/login.html", False
    .setRequestHeader "Content-type", "application/x-www-form-urlencoded" 'send appropriate Headers
    .send "userlogin=true&user=USERNAME&pass=PASSWORD&authcode=false" ' send login info
    'MsgBox xml.responseText
    .Open "GET", "https://www.XXXXXX.xx/account/callLog.html", False
    .setRequestHeader "Content-type", "text/xml"
    .send
    End With
    
    html.body.innerHTML = xml.responseText
    
    Set objTable = html.getElementsByTagName("table")
        For lngTable = 0 To objTable.Length - 1
            For lngRow = 0 To objTable(lngTable).Rows.Length - 1
                For lngCol = 0 To objTable(lngTable).Rows(lngRow).Cells.Length - 1
                    ThisWorkbook.Sheets("Sheet2").Cells(ActRw + lngRow + 1, lngCol + 1) = objTable(lngTable).Rows(lngRow).Cells(lngCol).innerText
                Next lngCol
            Next lngRow
            ActRw = ActRw + objTable(lngTable).Rows.Length + 1
        Next lngTable
    End Sub
    P.S. : i don't take any credits for this code, i manage to do it with help from different forums members!
    Last edited by mecanicu; 03-29-2017 at 07:07 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Assigning value for each scraped row based on another cell
    By Anka in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-14-2016, 08:03 PM
  2. Replies: 2
    Last Post: 01-07-2016, 12:25 PM
  3. How to Organize Scraped Data
    By anartey in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-20-2015, 02:13 AM
  4. web extract via swarm method - getting html objects and/or tables possible?
    By JasperD in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-12-2015, 05:35 PM
  5. Cleaning up Data Scraped From the Web by Deleting Certain Rows
    By torchD. in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-20-2015, 10:52 AM
  6. VBA to Import HTML Table Locally Stored HTML file to excel
    By ermengard in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-09-2015, 10:48 AM
  7. hii all is there any method to openthe html using vb command
    By vipul027 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-28-2014, 05:32 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1