Processing
 

VBA and IE8 - scrape text buried in table

05/09/2016 14:50#1

Joined at: 4 months ago

Post: 2

Thank: 0

Thanked: 0

I had an earlier question solved by the beautiful Tim Williams, but I've become stuck again. Finding resources for scraping using ie8 is quite difficult.

This is my current code now

Sub Scraper()  Dim item As Long Dim price1 As String Dim obj As Object   item = "10011" 'this will eventually be placed in a loop for multiple searches  Set objIE = CreateObject("InternetExplorer.Application")     objIE.Visible = True 'navigate and download the web page     objIE.Navigate "http://*********.aspx?UID=" & item & "~***" Do While objIE.ReadyState <> 4 Or objIE.Busy     DoEvents Loop      'keeping lines for reference, but increased speed by adding data to URL - do not need anymore     'objIE.Document.getElementsByTagName("input")(0).Value = item     'objIE.Document.getElementByID("FGC").Click  Set housePrice = objIE.Document.getElementByID("price_FGC")   End Sub 

I am trying to get the price of an item that's inside an HTML Table. I found the ID of the table, "price_FGC", but the actual price is nested inside that ID. I tried using a .innerText, but it either isn't supported within ie8 or I did it wrong. Here's a screenshot of the element tree:

VBA and IE8 - scrape text buried in table

I've seen some examples about adding "children" to some lines, but no real examples speaking to a situation like this. I also know that excel can grab table data "en masse," but I am doing this for a specific reason due to available resources and iterability.

SOLVED: Thanks to @Nathan_Sav for the help. Posted for others with similar issues and only access to IE8. Corrected variable names to make more sense for my coworkers :D

   Sub Scraper()     Dim item As Long    Dim priceStr As String    Dim priceTag As Object    Dim priceTable As Object      item = "10011" 'this will eventually be placed in a loop for multiple searches     Set objIE = CreateObject("InternetExplorer.Application")    objIE.Visible = True    ' navigate and download the web page    objIE.Navigate "http://******.aspx?UID=" & item & "~***"    Do While objIE.ReadyState <> 4 Or objIE.Busy      DoEvents    Loop    'objIE.Document.getElementsByTagName("input")(0).Value = item   'objIE.Document.getElementByID("FDI").Click    Set priceTable = objIE.Document.getElementByID("price_FGC")   Set priceTag = priceTable.getElementsByTagName("u")(3)   priceStr = priceTag.innerText    Sheet1.Range("A1").Value = priceStr    objIE.Quit     End Sub 
05/09/2016 16:32Top#2

Joined at: 9 months ago

Post: 4

Thank: 0

Thanked: 0

Added as answer :

houseprice.getelementsbytagname("td") or maybe "u"

@Nathan_Sav, thanks man! I set a new object equal to the getElementsByTagName("u") and used my Locals window in VBA to find the right item number. I'll edit my post with the finished product.

Similar articles

IE9 dosen't support my Button Tag

4 months ago - Reply: 0 - Views: 14

SSRS 2016 Web protal in IE8

4 months ago - Reply: 0 - Views: 13

how to handle @keyframes not supported by ie9?

4 months ago - Reply: 0 - Views: 5

Detect Windows XP in Firefox with JS

4 months ago - Reply: 1 - Views: 47

IE8 Not showing divs with floats

4 months ago - Reply: 2 - Views: 130

Including ECMA 5 script in IE8

5 months ago - Reply: 1 - Views: 98

XDomainRequest does not work in ie8 & ie9

5 months ago - Reply: 0 - Views: 10

How to minify angular.js?

5 months ago - Reply: 1 - Views: 30

VBA and IE8 - scrape text buried in table

5 months ago - Reply: 1 - Views: 37

Detect http satus IE10

5 months ago - Reply: 0 - Views: 6

how to compress angular.js?

5 months ago - Reply: 0 - Views: 3

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re