Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Web Browser Inner Text 1

Status
Not open for further replies.

Error7

Programmer
Jul 5, 2002
656
GB
I am trying to read this source which is displayed when I right click on the webpage and click View Source.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="/main.css" rel="stylesheet" type="text/css">
<link href="/main_new.css" rel="stylesheet" type="text/css">
<title>3/7B M61 QW17-MS3 - K SPUR</title>
<script>

function updateImage(){
document.images['camImage'].src = "/cctvpublicaccess/images/35237.jpg?sid=" + Math.random();
}

</script>
</head>
<body style="background-color: rgb(225,238,246);" onload="updateImage();">
<img src="" name='camImage' id='camImage' style='position: relative; top: 0;left:0;'></img>
<div align="center" style='position: relative;'><b>Camera: 35237 - 3/7B M61 QW17-MS3 - K SPUR</b> &nbsp&nbsp&nbsp&nbsp <a href="#" onclick="updateImage();" title="Images are refreshed every 30 seconds">Refresh</a></div>
<div align="center" style='position: relative;'><b>The carriageway closest to the camera is Southbound</b></div>
</body>
</html>

I have tried:

WB1.Document.documentElement.innerHTMl
WB1.Document.documentElement.OuterHTML
WB1.Document.Body.InnerText

None of which display the source as displayed above. Can somebody please point me in the right direction with this.

[gray]Experience is something you don't get until just after you need it.[/gray]
 
Intriguing how seemingly difficult that is.
Now I found out how to do it after all. You won't need the HTML objects for that.
What you need is an "Inet" control.
Set reference to "Microsoft Internet Transfer Controls" and add a Inet control to your form.
Then, adapt this code to your needs:
Code:
Private Sub Form_Load()
Dim SCode As String

SCode = GetHTML("[URL unfurl="true"]http://www.tek-tips.com")[/URL]
'output the source code to wherever you like

End Sub


Private Function GetHTML(url$) As String
Dim response$
Dim vData As Variant

  Inet1.Cancel
   response = Inet1.OpenURL(url)
  If response <> "" Then
    Do
      vData = Inet1.GetChunk(1024, icString)
      DoEvents
      If Len(vData) Then
        response = response & vData
      End If
    Loop While Len(vData)
  End If
   GetHTML = response
End Function

Credits to Bean from vbforums:

That whas tougher than expected...

Cheers,
MakeItSo

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Thanks MakeItSo, I did try your latest suggestion but unfortunately that returns "Access to the specified resource is forbidden."

I can manage with Andy's suggestion of using the second part of the URL. That displays the source that contains the information I need.

Alan

[gray]Experience is something you don't get until just after you need it.[/gray]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top