0

I have to derive the price table from http://www.idealo.de/preisvergleich/OffersOfProduct/143513.html

So far I have done this code

Sub test()       

  Set sht = Sheets("Tabelle4")
  rCount = 1

    Dim objIE As Object, objTbl As Object, objTR As Object
    Set objIE = CreateObject("InternetExplorer.application")

    With objIE
        .Visible = True
        .Navigate "http://www.idealo.de/preisvergleich/OffersOfProduct/143513.html"

        Do While .Busy Or .ReadyState <> 4
            DoEvents
        Loop

        Set objTbl = objIE.Document.getElementById("offers-list")
        Set objTR = objTbl.getElementsByTagName("tr")


        rCount = 1
        On Error Resume Next
        For Each td In objTR
            Cells(rCount, 1) = td.all(0).outerText
            Cells(rCount, 2) = td.all(4).innerText

            'Cells(rCount, 3) = td.all(2).outerText
            'Cells(rCount, 4) = td.all(3).outerText

            'Cells(rCount, 6) = td.all(5).innerText
            'Cells(rCount, 7) = td.all(6).innerText
            rCount = rCount + 1
        Next
        On Error GoTo 0

    End With

    objIE.Quit
    Set objIE = Nothing

End Sub

It gives me first two column but the last column that contains the shop name is not displaying. Can any one help which one is the td() of the last column

Cris
  • 12,799
  • 5
  • 35
  • 50
user3305327
  • 897
  • 4
  • 18
  • 34
  • Why are you using VBA for this? A simple Data|From Web will get you everything that you want? You may want to see [2) Using Excel's inbuilt facility to get data from the web](http://stackoverflow.com/questions/8798260/html-parsing-of-cricinfo-scorecards/8846791#8846791) I just tried it and it works. – Siddharth Rout Feb 20 '14 at 09:32
  • @SiddharthRout i need to develop a price comparison tool that's why am using vba – user3305327 Feb 20 '14 at 10:06
  • in that case in the above link, there is vba code for that as well. – Siddharth Rout Feb 20 '14 at 10:09

1 Answers1

0

In order to figure what type of data each td object has you have to add them to the watch. For example:

enter image description here

enter image description here

enter image description here

As you can see, in the td object I am watching i can tell that the value of

td.all.item(0).innertext 

is: Canon Nah­linse 500D 72 mm

Now you should go through the other values in the watch window until you can find the index of the shop in the td object

Math4123
  • 1,267
  • 4
  • 12
  • 23