Results 1 to 5 of 5

get all row of paginated table from webpage

Threaded View

  1. #1
    Registered User
    Join Date
    10-05-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    42

    Question get all row of paginated table from webpage

    Good day,

    I just want a little help on how to get all rows base on a paginated table. I have a working code below but it only takes the first page. I want to pull all the row on all paginated page if possible.

    My code below (this works on page 1 only):

    Sub GetData2()
    Dim ie As Object, i As Long, strText As String
    
       Dim doc As Object, hTable As Object, hBody As Object, hTR As Object, hTD As Object
       Dim tb As Object, bb As Object, tr As Object, td As Object
    
       Dim y As Long, z As Long, wb As Excel.Workbook, ws As Excel.Worksheet
    
         Set wb = Excel.ActiveWorkbook
         Set ws = wb.ActiveSheet
    
         Set ie = CreateObject("InternetExplorer.Application")
         ie.Visible = True
    
          y = 1   'Column A in Excel
          z = 1   'Row 1 in Excel
    
         ie.navigate "webpage with pagination here", , , , "Content-Type: application/x-www-form-urlencoded" & vbCrLf
    
         Do While ie.busy: DoEvents: Loop
         Do While ie.readyState <> 4: DoEvents: Loop
    
         Set doc = ie.document
         Set hTable = doc.getElementsByTagName("table")
    
    
         For Each tb In hTable
    
            Set hBody = tb.getElementsByTagName("tbody")
            For Each bb In hBody
    
                Set hTR = bb.getElementsByTagName("tr")
                For Each tr In hTR
    
    
                     Set hTD = tr.getElementsByTagName("td")
                     y = 1 ' Resets back to column A
                     For Each td In hTD
                       ws.Cells(z, y).Value = td.innerText
                       y = y + 1
                     Next td
                     DoEvents
                     z = z + 1
                Next tr
                Exit For
            Next bb
        Exit For
      Next tb
    
    End Sub
    Thank you guys for helping.
    Last edited by adbasanta; 05-24-2016 at 01:13 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. get the table from webpage to excel
    By mrkhchan in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 04-16-2015, 06:22 AM
  2. Extracting table from webpage
    By amber_skanpur in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-04-2014, 10:12 AM
  3. Get table data from webpage
    By nikanuka in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-17-2014, 10:57 AM
  4. Table Data (TD) on webpage and VBA
    By Jimbo77 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-22-2014, 04:52 AM
  5. Webpage table not copying into excel
    By aliu in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-03-2013, 01:23 AM
  6. Get html table from webpage to excel
    By prayami in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-28-2008, 05:38 AM
  7. How do I paste part of a table on a webpage?
    By sapphire in forum Excel General
    Replies: 0
    Last Post: 06-23-2008, 11:47 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