New Q to old Post: Stuck at Trying to Extract Data from a Website using JSP

H

H Chan

Hope I am not irritating anyone, but I indeed want to know how to extract
the information contained in the tagname "HTML" of an IE page to a cell.

My detailed question and previous discussion is copied below:

===================

I've run your macro, and it seems that the tagname "html" contains all the
text on the page, including the popup box.

I know nothing about how to control IE. How can I access the content of the
tagname "html" on the page?

I've tried:
Sheets("Sheet2").Range("a1").Value = IE.document.HTML

But the above gives me an error.

Hope you are still following the thread.

Thanks.

Herbert
 
N

norie

Herbert

Take a look at innerHTML or outerHTML.

Perhaps something like this.

MsgBox doc.getelementsbytagname("HTML")(0).innerhtml

By the way what is it you actually want to do in the other thread?

If for example you want to get every SCRIPT element.

For Each scr In doc.getelementsbytagname("SCRIPT")
MsgBox scr.innerhtml
Next scr
 
J

Joel

This is what you asked for.

Set HTMLTAG = IE.document.getElementsByTagName("HTMP")
RowCount = 1
for each itm in HTMLTag
Sheets("Sheet2").Range("a" & rowcount).Value = itm.innertext
RowCount = RowCount + 1
next itm


This is what I think you really want. the is no HTML tag. there are four
properties you can get.
1) innertext (in code below)
2) innerhtml
3) outertext
4) outerhtml

If you take the entire string the excel sheet will get an error because the
limits on the length of a text string. I only put the 1st 1024 character in
the worksheet cell in the code below.

RowCount = 1
with Sheets("Sheet2")
for each itm in IE.document.all
.Range("A" & rowcount).Value = itm.tagname
.Range("B" & rowcount).Value = itm.classname
.Range("C" & rowcount).Value = left(itm.innertext ,1024)
RowCount = RowCount + 1
next itm
end with
 

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