Connecting Tech Pros Worldwide Forums | Help | Site Map

Read page info from WebBrowser control?

Noozer
Guest
 
Posts: n/a
#1: Jul 17 '05
I am able to place values on forms that load into my webbrowser control, but
I'd like to be able to scan the page for data. I know to use the
HTMLDocument object.

Basically I'm hoping to find an example of a DocumentComplete routine that
will:

- display a list of all elements (tags?) on the page
- number of forms on the page
- ID, name, type and value for each field on the form
- and how I should handle a page with multiple frames.

I've found numerous examples through Google, but they are all VERY simple as
they assume you know what form index and element names are on the page
already. I can't find any samples that can scan a random page and produce
some output.

Thanks!



mayayana
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Read page info from WebBrowser control?


You need to research the IE DOM. It's all there.
The "all" collection gives you all tags in the page.
Each item in the "all" collection is an IHTMLElement
object. An IHTMLElement may also have children
IHTMLElements. Each has a Tagname property,
access to get and put attributes, catch events, etc.
You can do just about anything to the page that you
want to.

--
--
Noozer <dont.spam@me.here> wrote in message
news:mv_oc.475330$Ig.437986@pd7tw2no...[color=blue]
> I am able to place values on forms that load into my webbrowser control,[/color]
but[color=blue]
> I'd like to be able to scan the page for data. I know to use the
> HTMLDocument object.
>
> Basically I'm hoping to find an example of a DocumentComplete routine that
> will:
>
> - display a list of all elements (tags?) on the page
> - number of forms on the page
> - ID, name, type and value for each field on the form
> - and how I should handle a page with multiple frames.
>
> I've found numerous examples through Google, but they are all VERY simple[/color]
as[color=blue]
> they assume you know what form index and element names are on the page
> already. I can't find any samples that can scan a random page and produce
> some output.
>
> Thanks!
>
>[/color]


steve b
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Read page info from WebBrowser control?


Can you send an enter key press?

"mayayana" <mayaXXyaYYna1a@mindZZspring.com> wrote in message
news:At3pc.9321$KE6.7175@newsread3.news.atl.earthl ink.net...[color=blue]
> You need to research the IE DOM. It's all there.
> The "all" collection gives you all tags in the page.
> Each item in the "all" collection is an IHTMLElement
> object. An IHTMLElement may also have children
> IHTMLElements. Each has a Tagname property,
> access to get and put attributes, catch events, etc.
> You can do just about anything to the page that you
> want to.
>
> --
> --
> Noozer <dont.spam@me.here> wrote in message
> news:mv_oc.475330$Ig.437986@pd7tw2no...[color=green]
> > I am able to place values on forms that load into my webbrowser control,[/color]
> but[color=green]
> > I'd like to be able to scan the page for data. I know to use the
> > HTMLDocument object.
> >
> > Basically I'm hoping to find an example of a DocumentComplete routine[/color][/color]
that[color=blue][color=green]
> > will:
> >
> > - display a list of all elements (tags?) on the page
> > - number of forms on the page
> > - ID, name, type and value for each field on the form
> > - and how I should handle a page with multiple frames.
> >
> > I've found numerous examples through Google, but they are all VERY[/color][/color]
simple[color=blue]
> as[color=green]
> > they assume you know what form index and element names are on the page
> > already. I can't find any samples that can scan a random page and[/color][/color]
produce[color=blue][color=green]
> > some output.
> >
> > Thanks!
> >
> >[/color]
>
>[/color]


mayayana
Guest
 
Posts: n/a
#4: Jul 17 '05

re: Read page info from WebBrowser control?


You mean send it to the page?

'-- assuming you've got the document object as Doc:

Dim TR As IHTMLTxtRange
Set TR = Doc.Body.CreateTextRange
TR.pasteHtml "<BR>"
(You may need to also paste a "#nbsp;" to actually
show the return in the page. And you can use the Move,
MoveToPoint, etc. methods to position where the return
happens.)

If you mean a SendKeys to the WB window, in order
to "click" something, I don't know the best way to do that.
[color=blue]
> Can you send an enter key press?
>[/color]
[color=blue][color=green]
> > You need to research the IE DOM. It's all there.
> > The "all" collection gives you all tags in the page.
> > Each item in the "all" collection is an IHTMLElement
> > object. An IHTMLElement may also have children
> > IHTMLElements. Each has a Tagname property,
> > access to get and put attributes, catch events, etc.
> > You can do just about anything to the page that you
> > want to.
> >
> > --
> > --
> > Noozer <dont.spam@me.here> wrote in message
> > news:mv_oc.475330$Ig.437986@pd7tw2no...[color=darkred]
> > > I am able to place values on forms that load into my webbrowser[/color][/color][/color]
control,[color=blue][color=green]
> > but[color=darkred]
> > > I'd like to be able to scan the page for data. I know to use the
> > > HTMLDocument object.
> > >
> > > Basically I'm hoping to find an example of a DocumentComplete routine[/color][/color]
> that[color=green][color=darkred]
> > > will:
> > >
> > > - display a list of all elements (tags?) on the page
> > > - number of forms on the page
> > > - ID, name, type and value for each field on the form
> > > - and how I should handle a page with multiple frames.
> > >
> > > I've found numerous examples through Google, but they are all VERY[/color][/color]
> simple[color=green]
> > as[color=darkred]
> > > they assume you know what form index and element names are on the page
> > > already. I can't find any samples that can scan a random page and[/color][/color]
> produce[color=green][color=darkred]
> > > some output.
> > >
> > > Thanks!
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Chipmonk
Guest
 
Posts: n/a
#5: Jul 17 '05

re: Read page info from WebBrowser control?


Hi mayayana,

How could you move a vertical scroll bar down to the bottom?

My problem is that when I insert a line of text into an Internet
Explorer_Server window, the document fails to scroll up, and so the new line
of text is not visible (unless I manually scroll up by clicking the bottom
of the scroll bar).


PS. Could someone please repost this message to the original list of
newsgroups
(comp.lang.basic.visual,comp.lang.visual.basic,mic rosoft.public.vb.controls.
internet) as I only have access to the MS news server, and I don't think
mayayana is subscribed here. Thanks.

"mayayana" <mayaXXyaYYna1a@mindZZspring.com> wrote in message
news:At3pc.9321$KE6.7175@newsread3.news.atl.earthl ink.net...[color=blue]
> You need to research the IE DOM. It's all there.
> The "all" collection gives you all tags in the page.
> Each item in the "all" collection is an IHTMLElement
> object. An IHTMLElement may also have children
> IHTMLElements. Each has a Tagname property,
> access to get and put attributes, catch events, etc.
> You can do just about anything to the page that you
> want to.
>
> --
> --
> Noozer <dont.spam@me.here> wrote in message
> news:mv_oc.475330$Ig.437986@pd7tw2no...[color=green]
> > I am able to place values on forms that load into my webbrowser control,[/color]
> but[color=green]
> > I'd like to be able to scan the page for data. I know to use the
> > HTMLDocument object.
> >
> > Basically I'm hoping to find an example of a DocumentComplete routine[/color][/color]
that[color=blue][color=green]
> > will:
> >
> > - display a list of all elements (tags?) on the page
> > - number of forms on the page
> > - ID, name, type and value for each field on the form
> > - and how I should handle a page with multiple frames.
> >
> > I've found numerous examples through Google, but they are all VERY[/color][/color]
simple[color=blue]
> as[color=green]
> > they assume you know what form index and element names are on the page
> > already. I can't find any samples that can scan a random page and[/color][/color]
produce[color=blue][color=green]
> > some output.
> >
> > Thanks!
> >
> >[/color]
>
>[/color]


mayayana
Guest
 
Posts: n/a
#6: Jul 17 '05

re: Read page info from WebBrowser control?


I'm not sure about that. You can scroll the page with this:
WB.Document.body.scrolltop

It's a Read/Write Long value in pixels that can return or set
the pixel point showing at the top of the browser window.
To scroll to the bottom I guess you'd need to get the page height
and window height to figure it out. Or maybe you could just
set scrolltop to something very large. In other words, if the
page is 800 pixels high and the window is 700 pixels high
then setting scrolltop to 100 would scroll to the bottom. I'm
guessing that setting scrolltop to, say, 2000 might also work.
[color=blue]
> How could you move a vertical scroll bar down to the bottom?
>
> My problem is that when I insert a line of text into an Internet
> Explorer_Server window, the document fails to scroll up, and so the new[/color]
line[color=blue]
> of text is not visible (unless I manually scroll up by clicking the bottom
> of the scroll bar).
>
>
> PS. Could someone please repost this message to the original list of
> newsgroups
>[/color]
(comp.lang.basic.visual,comp.lang.visual.basic,mic rosoft.public.vb.controls.[color=blue]
> internet) as I only have access to the MS news server, and I don't think
> mayayana is subscribed here. Thanks.
>
> "mayayana" <mayaXXyaYYna1a@mindZZspring.com> wrote in message
> news:At3pc.9321$KE6.7175@newsread3.news.atl.earthl ink.net...[color=green]
> > You need to research the IE DOM. It's all there.
> > The "all" collection gives you all tags in the page.
> > Each item in the "all" collection is an IHTMLElement
> > object. An IHTMLElement may also have children
> > IHTMLElements. Each has a Tagname property,
> > access to get and put attributes, catch events, etc.
> > You can do just about anything to the page that you
> > want to.
> >
> > --
> > --
> > Noozer <dont.spam@me.here> wrote in message
> > news:mv_oc.475330$Ig.437986@pd7tw2no...[color=darkred]
> > > I am able to place values on forms that load into my webbrowser[/color][/color][/color]
control,[color=blue][color=green]
> > but[color=darkred]
> > > I'd like to be able to scan the page for data. I know to use the
> > > HTMLDocument object.
> > >
> > > Basically I'm hoping to find an example of a DocumentComplete routine[/color][/color]
> that[color=green][color=darkred]
> > > will:
> > >
> > > - display a list of all elements (tags?) on the page
> > > - number of forms on the page
> > > - ID, name, type and value for each field on the form
> > > - and how I should handle a page with multiple frames.
> > >
> > > I've found numerous examples through Google, but they are all VERY[/color][/color]
> simple[color=green]
> > as[color=darkred]
> > > they assume you know what form index and element names are on the page
> > > already. I can't find any samples that can scan a random page and[/color][/color]
> produce[color=green][color=darkred]
> > > some output.
> > >
> > > Thanks!
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Chipmonk
Guest
 
Posts: n/a
#7: Jul 17 '05

re: Read page info from WebBrowser control?


Hi mayayana,

My object doesn't seem to have that property. I've tried several other
suggestions seen on Web sites too, but none of them seem to work with this
object.

I'm using this code
http://www.planet-source-code.com/vb...50433&lngWId=1
to attach onto the new Yahoo! Messenger 6 BETA's
http://messenger.yahoo.com/beta/winbeta.php IM windows (Yahoo! uses the
Internet Explorer_Server). The code works very well.

My program inserts a status message into my IM window. If Messenger already
had a status message showing in the window, then my program deletes the
status HTML code and inserts my own to show the new status message. This
works seemlessly.

The problem only arrises when there wasn't already a status there. If I just
insert my own status, the IM window doesn't scroll up as it normally does.
The user is left to scroll up manually, although from then on the window
scrolls automatically as normal.

I've compared all the innerHTML and outerHTML code of when Messenger inserts
it's status with when my program inserts a status, and they are identicle.

So the question is, when Messenger inserts a status for the first time, what
else does it do to ensure the window scrolls? I've seen a .autoscroll
method, but it had no effect either.

Any ideas? I suppose I would be too lucky if you're a Yahoo! Messenger user
:)

"mayayana" <mayaXXyaYYna1a@mindZZspring.com> wrote in message
news:yrbrc.23329$KE6.18985@newsread3.news.atl.eart hlink.net...[color=blue]
> I'm not sure about that. You can scroll the page with this:
> WB.Document.body.scrolltop
>
> It's a Read/Write Long value in pixels that can return or set
> the pixel point showing at the top of the browser window.
> To scroll to the bottom I guess you'd need to get the page height
> and window height to figure it out. Or maybe you could just
> set scrolltop to something very large. In other words, if the
> page is 800 pixels high and the window is 700 pixels high
> then setting scrolltop to 100 would scroll to the bottom. I'm
> guessing that setting scrolltop to, say, 2000 might also work.
>[color=green]
> > How could you move a vertical scroll bar down to the bottom?
> >
> > My problem is that when I insert a line of text into an Internet
> > Explorer_Server window, the document fails to scroll up, and so the new[/color]
> line[color=green]
> > of text is not visible (unless I manually scroll up by clicking the[/color][/color]
bottom[color=blue][color=green]
> > of the scroll bar).
> >
> >
> > PS. Could someone please repost this message to the original list of
> > newsgroups
> >[/color]
>[/color]
(comp.lang.basic.visual,comp.lang.visual.basic,mic rosoft.public.vb.controls.[color=blue][color=green]
> > internet) as I only have access to the MS news server, and I don't think
> > mayayana is subscribed here. Thanks.
> >
> > "mayayana" <mayaXXyaYYna1a@mindZZspring.com> wrote in message
> > news:At3pc.9321$KE6.7175@newsread3.news.atl.earthl ink.net...[color=darkred]
> > > You need to research the IE DOM. It's all there.
> > > The "all" collection gives you all tags in the page.
> > > Each item in the "all" collection is an IHTMLElement
> > > object. An IHTMLElement may also have children
> > > IHTMLElements. Each has a Tagname property,
> > > access to get and put attributes, catch events, etc.
> > > You can do just about anything to the page that you
> > > want to.
> > >
> > > --
> > > --
> > > Noozer <dont.spam@me.here> wrote in message
> > > news:mv_oc.475330$Ig.437986@pd7tw2no...
> > > > I am able to place values on forms that load into my webbrowser[/color][/color]
> control,[color=green][color=darkred]
> > > but
> > > > I'd like to be able to scan the page for data. I know to use the
> > > > HTMLDocument object.
> > > >
> > > > Basically I'm hoping to find an example of a DocumentComplete[/color][/color][/color]
routine[color=blue][color=green]
> > that[color=darkred]
> > > > will:
> > > >
> > > > - display a list of all elements (tags?) on the page
> > > > - number of forms on the page
> > > > - ID, name, type and value for each field on the form
> > > > - and how I should handle a page with multiple frames.
> > > >
> > > > I've found numerous examples through Google, but they are all VERY[/color]
> > simple[color=darkred]
> > > as
> > > > they assume you know what form index and element names are on the[/color][/color][/color]
page[color=blue][color=green][color=darkred]
> > > > already. I can't find any samples that can scan a random page and[/color]
> > produce[color=darkred]
> > > > some output.
> > > >
> > > > Thanks!
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


mayayana
Guest
 
Posts: n/a
#8: Jul 17 '05

re: Read page info from WebBrowser control?


Sorry. I've never used IM, so I only have a vague
idea of what you're talking about.

--[color=blue]
>
> My object doesn't seem to have that property. I've tried several other
> suggestions seen on Web sites too, but none of them seem to work with this
> object.
>
> I'm using this code
>[/color]
http://www.planet-source-code.com/vb...odeId=50433&ln
gWId=1[color=blue]
> to attach onto the new Yahoo! Messenger 6 BETA's
> http://messenger.yahoo.com/beta/winbeta.php IM windows (Yahoo! uses the
> Internet Explorer_Server). The code works very well.
>
> My program inserts a status message into my IM window. If Messenger[/color]
already[color=blue]
> had a status message showing in the window, then my program deletes the
> status HTML code and inserts my own to show the new status message. This
> works seemlessly.
>
> The problem only arrises when there wasn't already a status there. If I[/color]
just[color=blue]
> insert my own status, the IM window doesn't scroll up as it normally does.
> The user is left to scroll up manually, although from then on the window
> scrolls automatically as normal.
>
> I've compared all the innerHTML and outerHTML code of when Messenger[/color]
inserts[color=blue]
> it's status with when my program inserts a status, and they are identicle.
>
> So the question is, when Messenger inserts a status for the first time,[/color]
what[color=blue]
> else does it do to ensure the window scrolls? I've seen a .autoscroll
> method, but it had no effect either.
>
> Any ideas? I suppose I would be too lucky if you're a Yahoo! Messenger[/color]
user[color=blue]
> :)
>
> "mayayana" <mayaXXyaYYna1a@mindZZspring.com> wrote in message
> news:yrbrc.23329$KE6.18985@newsread3.news.atl.eart hlink.net...[color=green]
> > I'm not sure about that. You can scroll the page with this:
> > WB.Document.body.scrolltop
> >
> > It's a Read/Write Long value in pixels that can return or set
> > the pixel point showing at the top of the browser window.
> > To scroll to the bottom I guess you'd need to get the page height
> > and window height to figure it out. Or maybe you could just
> > set scrolltop to something very large. In other words, if the
> > page is 800 pixels high and the window is 700 pixels high
> > then setting scrolltop to 100 would scroll to the bottom. I'm
> > guessing that setting scrolltop to, say, 2000 might also work.
> >[color=darkred]
> > > How could you move a vertical scroll bar down to the bottom?
> > >
> > > My problem is that when I insert a line of text into an Internet
> > > Explorer_Server window, the document fails to scroll up, and so the[/color][/color][/color]
new[color=blue][color=green]
> > line[color=darkred]
> > > of text is not visible (unless I manually scroll up by clicking the[/color][/color]
> bottom[color=green][color=darkred]
> > > of the scroll bar).
> > >
> > >
> > > PS. Could someone please repost this message to the original list of
> > > newsgroups
> > >[/color]
> >[/color]
>[/color]
(comp.lang.basic.visual,comp.lang.visual.basic,mic rosoft.public.vb.controls.[color=blue][color=green][color=darkred]
> > > internet) as I only have access to the MS news server, and I don't[/color][/color][/color]
think[color=blue][color=green][color=darkred]
> > > mayayana is subscribed here. Thanks.
> > >
> > > "mayayana" <mayaXXyaYYna1a@mindZZspring.com> wrote in message
> > > news:At3pc.9321$KE6.7175@newsread3.news.atl.earthl ink.net...
> > > > You need to research the IE DOM. It's all there.
> > > > The "all" collection gives you all tags in the page.
> > > > Each item in the "all" collection is an IHTMLElement
> > > > object. An IHTMLElement may also have children
> > > > IHTMLElements. Each has a Tagname property,
> > > > access to get and put attributes, catch events, etc.
> > > > You can do just about anything to the page that you
> > > > want to.
> > > >
> > > > --
> > > > --
> > > > Noozer <dont.spam@me.here> wrote in message
> > > > news:mv_oc.475330$Ig.437986@pd7tw2no...
> > > > > I am able to place values on forms that load into my webbrowser[/color]
> > control,[color=darkred]
> > > > but
> > > > > I'd like to be able to scan the page for data. I know to use the
> > > > > HTMLDocument object.
> > > > >
> > > > > Basically I'm hoping to find an example of a DocumentComplete[/color][/color]
> routine[color=green][color=darkred]
> > > that
> > > > > will:
> > > > >
> > > > > - display a list of all elements (tags?) on the page
> > > > > - number of forms on the page
> > > > > - ID, name, type and value for each field on the form
> > > > > - and how I should handle a page with multiple frames.
> > > > >
> > > > > I've found numerous examples through Google, but they are all VERY
> > > simple
> > > > as
> > > > > they assume you know what form index and element names are on the[/color][/color]
> page[color=green][color=darkred]
> > > > > already. I can't find any samples that can scan a random page and
> > > produce
> > > > > some output.
> > > > >
> > > > > Thanks!
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Closed Thread


Similar Visual Basic 4 / 5 / 6 bytes