Retrieving data from Web page 2

U

user88

Hi,

I have tried this also, I don't see the data from the webpage.

How to resolve?


re: http://www.investor.reuters.wallst.com/stocks/Ratios.asp?ticker=IBM

Trying to retrieve specific info from the web page.
ie: EPS (TTM) vs TTM 1 Yr. Ago

I can't seem to retrieve any data from the page, I have tried using the
following:

#1:
'Microsoft.XMLHTTP, MS COM object to retrieve data from another website via
HTTP requests
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")

#2:
Set oIE = New SHDocVw.InternetExplorer
'Open the web page
oIE.Navigate
"http://www.investor.reuters.wallst.com/stocks/Ratios.asp?ticker=IBM


What is the best way to retrieve the data from this page?


Thanks.
 
T

Tim Williams

The methods you show are valid, but again you have provided no details of what you've tried and exactly in what way they didn't work
for you...

How/where are you trying to "see" the data?
 
P

Peter Huang [MSFT]

Dear Customer,

I agree Tim's suggestion?
What is the data you are trying to get and what trouble did you encounter?
e.g. if you use the approach 2, the IE window should show the page just as
you open the IE and input the URL and press Enter.
So I just wonder what is your concern now?

<quote>
#2:
Set oIE = New SHDocVw.InternetExplorer
'Open the web page
oIE.Navigate
"http://www.investor.reuters.wallst.com/stocks/Ratios.asp?ticker=IBM
</quote>

Thanks!

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
N

NickHK

You can use an Excel web query, but make sure you select the "Entire Page"
option.
I'm not HTML expert, but it looks like the data is not really in a table but
in DIV/SPAN tags, so Excel can parse it as it in TABLE/TR/TD tags.
You'll have to do work then to get the data separated.

NickHK
 
T

Tim Williams

If using IE automation, you can access information from the page based on the id of the surrounding <span> element

Eg:

msgbox oIE.document.getElementById("LastChange_spQuoteLast").innerText
msgbox oIE.document.getElementById("LastChange_lblCurrency").innerText


where oIE is the IE object you're controlling.
 
M

mjack003

Using this method,

set mypagethtml = ie.document
Set tr = myPageHtml.body.createTextRange
Set tbl = myPageHtml.getElementById("<TableName>")

tr.moveToElementText (tbl)

I've got a bit of a problem since there are two tables with the sam
name on the html document and I need the second of the two. How woul
I go about moving to the second table so that I can copy it? I'v
pulled what little hair I have left out over this one.

Thanks,
Mjac
 
T

Tim Williams

dim cTables as object
set cTables = myPageHtml.getElementsByTagname("table")

will return a collection of the tables in the page.
Use cTables(1) or whichever represents the table you want.

Tables do not typically have a "name" attribute, and there should not be 2 elements with the same "id"...
 
M

mjack003

Thanks for the reply Tim. I didn't mention in my first post that the
two tables not only have identical names but ID's also. Don't know why
our IT dept created the GUI the way they did but the only way to access
the second table was to use an index. Hope this helps anyone with a
similar problem.

Best Regards,
Mjack
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top