+ Reply to Thread
Results 1 to 5 of 5

web query not importing table data

Hybrid View

  1. #1
    Registered User
    Join Date
    06-09-2014
    Posts
    3

    web query not importing table data

    Hi Friends,

    I am trying to import a table through web query from the following link. But its not importing the table probably becs its created in JavaScript and jquery. Can u guys pls help me?

    Note- I found a similar thread on another forum which has the code below. But it doesn't work on my URL

    http://www.nseindia.com/live_market/...ers_losers.htm


    Sub Dow_HistoricalData()
    
        Dim xmlHttp As Object
        Dim TR_col As Object, TR As Object
        Dim TD_col As Object, TD As Object
        Dim row As Long, col As Long
    
        Set xmlHttp = CreateObject("MSXML2.XMLHTTP.6.0")
        xmlHttp.Open "GET", "http://www.investing.com/indices/us-30-historical-data", False
        xmlHttp.setRequestHeader "Content-Type", "text/xml"
        xmlHttp.send
    
        Dim html As Object
        Set html = CreateObject("htmlfile")
        html.body.innerHTML = xmlHttp.ResponseText
    
        Dim tbl As Object
        Set tbl = html.getElementById("curr_table")
    
        row = 1
        col = 1
    
        Set TR_col = html.getelementsbytagname("TR")
        For Each TR In TR_col
            Set TD_col = TR.getelementsbytagname("TD")
            For Each TD In TD_col
                Cells(row, col) = TD.innerText
                col = col + 1
            Next
            col = 1
            row = row + 1
        Next
    End Sub
    Last edited by sowgat; 06-09-2014 at 02:10 PM.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: web query not importing table data


    Hi,

    I can't see your code (with tags …) !

  3. #3
    Registered User
    Join Date
    06-09-2014
    Posts
    3

    Re: web query not importing table data

    hi Marc,

    I have updated my post above. Please can you help?

    Thanks!

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: web query not importing table data


    In the code it's not the same URL neither the same table !

    Use inspector tool within your web navigator to update the code …

  5. #5
    Registered User
    Join Date
    06-09-2014
    Posts
    3

    Re: web query not importing table data

    hi Marc,

    I tried again with this new code. Didn't work. Please help.

    
    Sub Dow_HistoricalData()
    
        Dim xmlHttp As Object
        Dim TR_col As Object, TR As Object
        Dim TD_col As Object, TD As Object
        Dim row As Long, col As Long
    
        Set xmlHttp = CreateObject("MSXML2.XMLHTTP.6.0")
        xmlHttp.Open "GET", "http://nseindia.com/live_market/dynaContent/live_analysis/top_gainers_losers.htm", False
        xmlHttp.setRequestHeader "Content-Type", "text/xml"
        xmlHttp.send
    
        Dim html As Object
        Set html = CreateObject("htmlfile")
        html.body.innerHTML = xmlHttp.ResponseText
    
        Dim tbl As Object
        Set tbl = html.getElementById("tab7Content")
    
        row = 1
        col = 1
    
        Set TR_col = html.getelementsbytagname("th")
        For Each TR In TR_col
            Set TD_col = TR.getelementsbytagname("td")
            For Each TD In TD_col
                Cells(row, col) = TD.innerText
                col = col + 1
            Next
            col = 1
            row = row + 1
        Next
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 12-05-2012, 03:48 PM
  2. [QUERY] Help on importing .csv data
    By eenyweeny in forum Excel General
    Replies: 3
    Last Post: 10-30-2012, 03:25 PM
  3. Importing Data using SQL Query
    By dhatul in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-02-2011, 03:34 AM
  4. [SOLVED] Importing Data via Web Query - Can values be passed to query?
    By jgalenski@charter.net in forum Excel General
    Replies: 5
    Last Post: 05-09-2006, 01:25 PM
  5. [SOLVED] Importing a table from Access query
    By Trish in forum Excel General
    Replies: 1
    Last Post: 05-12-2005, 04:06 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