PDA

Click to See Complete Forum and Search --> : Saving HTML documents


koskinene
May 9th, 2001, 03:38 AM
I'm using webbrowser to for nagivation and displaying the contents of web pages. But how do I get webbrowser to save the pages onto disk and preferably without the HTML coding only ascii??

Many thanks for any ideas,
Eero

Matthew Gates
May 9th, 2001, 06:07 AM
Use this code to save a page:


Text1.Text = WebBrowser1.Document.documentElement.innerHTML

Or this one to save the whole web site.


WebBrowser1.ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_DODEFAULT


And use this code to remove the tags.


Private Function Tagless(ByVal Text As String) As String
Dim i As Integer
Dim bInTag As Boolean
Dim strTmpStr As String

bInTag = False
For i = 1 To Len(Text)
If Not bInTag Then
If Mid(Text, i, 1) <> "<" Then
strTmpStr = strTmpStr & Mid(Text, i, 1)
Else
bInTag = True
End If
Else
If Mid(Text, i, 1) = ">" Then
bInTag = False
End If
End If
Next

TagLess = strTmpStr
End Function

Private Sub Form_Load()
Dim strHTML As String
strHTML = "<HTML>" & _
"<HEAD>" & _
"<TITLE>Test Page</TITLE>" & _
"</HEAD>" & _
"<BODY>" & _
"Hello World!" & _
"</BODY>" & _
"</HTML>"
MsgBox Tagless(strHTML)
End Sub