Kaprice
asked on
VBA to Read data from IE Website
I'm working in MS Access 2010.
I've got code that opens an IE browser and navigates to a page.
Now I want to read various elements on the page. I have iMacros but it's not an ideal solution for me so I'm trying to do it all from VBA.
But, iMacros does appear to be very good at grabbing element names/ids.
Here's what iMacros came up with:
Apparently, POS indicates WHICH element it is.
Is that enough info to help me come up with VBA code that will read the text in those elements and store in a variable?
I've got code that opens an IE browser and navigates to a page.
Dim mobjIE As SHDocVw.InternetExplorer
Set mobjIE = New SHDocVw.InternetExplorer
mstrPage = vNewValue
mobjIE.navigate mstrPage
Now I want to read various elements on the page. I have iMacros but it's not an ideal solution for me so I'm trying to do it all from VBA.
But, iMacros does appear to be very good at grabbing element names/ids.
Here's what iMacros came up with:
TAG POS=4 TYPE=P ATTR=TXT:* EXTRACT=TXT
TAG POS=1 TYPE=SPAN ATTR=CLASS:style15 EXTRACT=TXT
TAG POS=1 TYPE=I ATTR=TXT:* EXTRACT=TXT
TAG POS=1 TYPE=SPAN ATTR=CLASS:style5 EXTRACT=TXT
TAG POS=2 TYPE=SPAN ATTR=CLASS:style5 EXTRACT=TXT
TAG POS=4 TYPE=STRONG ATTR=TXT:* EXTRACT=TXT
TAG POS=5 TYPE=STRONG ATTR=TXT:* EXTRACT=TXT
TAG POS=6 TYPE=STRONG ATTR=TXT:* EXTRACT=TXT
TAG POS=7 TYPE=STRONG ATTR=TXT:* EXTRACT=TXT
TAG POS=8 TYPE=STRONG ATTR=TXT:* EXTRACT=TXT
TAG POS=9 TYPE=STRONG ATTR=TXT:* EXTRACT=TXT
TAG POS=10 TYPE=STRONG ATTR=TXT:* EXTRACT=TXT
' Loop Reviews
TAG POS=1 TYPE=SPAN ATTR=CLASS:style11 EXTRACT=TXT
TAG POS=1 TYPE=IMG ATTR=SRC:*/images/star*.gif EXTRACT=HTM
TAG POS=1 TYPE=FONT ATTR=* EXTRACT=TXT
Apparently, POS indicates WHICH element it is.
Is that enough info to help me come up with VBA code that will read the text in those elements and store in a variable?
ASKER
What data do you want from the page?
ASKER
the ones i circled in the screenshots.
Right, I see now - had trouble opening the image files for some reason.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad you got it working.
Glad you got it working.
ASKER
I figured it out even though the expert said the iMacros info would not help.
Do you know what elements/data you want from the page?
Can you post the URL for the page?