Check webbrowser for 404 page not found

M

Manfred

Hello

I use the webbrowser control to navigate to some webpages. If the page
is not found I like to display some other controls.

I can't find the html source text in the webbrowser control
(documenttext is empty even there is some text diplayed). Is it possible
to retrieve this text and search for the 404?


Regards

Manfred
 
M

Manfred

Just figured it out myself:

Dim xy As HtmlDocument
xy = webbrowser1.Document
If xy.Body.InnerHtml.Contains("404") Then
.....

Regards

Manfred


xy.Body.OuterHtml = "<STRONG>Problem with
Internetconnection </STRONG>" & vbLf & "<P>&nbsp;</P>" & vbLf &
"<P>&nbsp;</P>"
xy.Body.InnerHtml = "<STRONG>Problem with
Internetconnection </STRONG>" & vbLf & "<P>&nbsp;</P>" & vbLf &
"<P>&nbsp;</P>"
End If
 
N

Number 11950 - GPEMC! Replace number with 11950

Manfred said:
Just figured it out myself:

Dim xy As HtmlDocument
xy = webbrowser1.Document
If xy.Body.InnerHtml.Contains("404") Then
....
[SNIP]
What if your page contains something like

Style="Height: 404px"

OR

628,404 tonnes

OR

<TD ID="404">

OR

SOLD! For US$404,999

SO, I suggest it may work better if you add some characters - a space either
side of 404 would be a good bet although "Our position was charged by no
less than 404 cavalrymen." could prove too tricky for space bracketting.
"HTTP 404"???

It gets better. Point your browser to http://www.realmeleven.com/sdrhf then
select "Source" from the View Menu and hitting the "F3" key, do a search for
404...

Some target pages may have the string 404 and some error pages may not.
Good luck!
 
G

Guest

The result page text is configurable on the server, so the 404 message may be
very descriptive and not include 404. for instance, try,
http://www.cnn.com/i_am_not_here.


Number 11950 - GPEMC! Replace number wit said:
Manfred said:
Just figured it out myself:

Dim xy As HtmlDocument
xy = webbrowser1.Document
If xy.Body.InnerHtml.Contains("404") Then
....
[SNIP]
What if your page contains something like

Style="Height: 404px"

OR

628,404 tonnes

OR

<TD ID="404">

OR

SOLD! For US$404,999

SO, I suggest it may work better if you add some characters - a space either
side of 404 would be a good bet although "Our position was charged by no
less than 404 cavalrymen." could prove too tricky for space bracketting.
"HTTP 404"???

It gets better. Point your browser to http://www.realmeleven.com/sdrhf then
select "Source" from the View Menu and hitting the "F3" key, do a search for
404...

Some target pages may have the string 404 and some error pages may not.
Good luck!

--
Timothy Casey GPEMC! >> 11950 is the (e-mail address removed) 2email
Terms & conditions apply. See www.fieldcraft.biz/GPEMC
Discover valid interoperable web menus, IE security, TSR Control,
& the most advanced speed reading application @ www.fieldcraft.biz
 
Joined
Oct 1, 2008
Messages
1
Reaction score
0
As a warning, I have noticed in using the .NET WebBrowser control that the WebBrowser.Document property is not valid until the DocumentCompleted event fires.
 
Last edited:

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