see WalkAll Sample in Web Workshop

解决方案 »

  1.   

    这没有什么意思呀!(只出现文本部分(就向ie另存的一样))
    她之存下HTML文件的标题呀!
    如果说你真这样做,
    几天后,我帮你做一个试试,OK!
      

  2.   

    我在网络上见过从TXT转化成HTML!
    没有见过从HTML转化成TXT。
      

  3.   

    使用IHtmlDocument接口获得BODY元素的innerText就可以了
      

  4.   

    to jiangsheng
    能具体一点吗,有没有 例程?
      

  5.   

    http://www.csdn.net/expert/topic/299/299106.shtm
      

  6.   

    to jiangshen:
    ......不好意思,我没学过vc
    只要告诉我是在vb的工程中加入什么库的调用
    以及相关的对象属性
      

  7.   

    不好意思,我没学过vc
    只要告诉我是在vb的工程中加入什么库的调用
    以及相关的对象属性 
      

  8.   

    "使用IHtmlDocument接口获得BODY元素的innerText就可以了 "
    这个Ihtmldocument接口在哪儿?
      

  9.   

    to asciiman:
    有创意的,又要去enumwindow了
    不过我想应该有简便的方法
      

  10.   

    我引用了Microsoft Internet Controls(shdocvw.dll)
    可以用navigate方法打开指定页面了
    不过还不知道如何保存页面,其中document属性一项不知怎么用,有高手提点一下吗
      

  11.   

    document属性返回一个IHtmlDocument2接口。
      

  12.   

    用webbrowser1.execWB ,在后面自动给出的选项中
    先   selectall
    然后 copy
    最后 paste
      

  13.   

    to lou_df(ldf):
       有点小问题,ExecWB cmdID,cmdExecept[,pvIn],[pvOut] 
    后三个参数怎么用?
        是在pvout 中指定输出的文件名吧?pvin是什么?
    cmdID不用saveas可以吗?
      

  14.   

    WebBrowser1.ExecWB OLECMDID_SAVEAS, 
    OLECMDEXECOPT_DONTPROMPTUSER, "c:\c.htm", "c:\c.htm" 就将控件中显示的页面保存到 c:\c.htm 
    但我执行时是会调出  saveas 对话框的,怎么才能不经过确认这一步?
      

  15.   

    自己写代码存到文件
    使用
    outerHTML Property (IHTMLElement)--------------------------------------------------------------------------------Sets or retrieves the object and its content in HTML.SyntaxHRESULT IHTMLElement::get_outerHTML(BSTR *p);HRESULT IHTMLElement::put_outerHTML(BSTR v);
    Parametersp
    Pointer to a BSTR that receives content and HTML tags.
    v
    BSTR that specifies content and HTML tags.
    Return ValueReturns S_OK if successful, or an error value otherwise. 
    ResThe IHTMLElement::outerHTML property is read-only on the HTML, HEAD, body, FRAMESET, TBODY, TD, TFOOT, TH, THEAD, and TR objects.The property can be any valid string containing a combination of text and tags.When the property is set, the given string completely replaces the object, including its start and end tags. If the string contains HTML tags, the string is parsed and formatted as it is placed into the document.This property is accessible at run time as of Microsoft® Internet Explorer 5. Removing elements at run time, before the closing tag has been parsed, can prevent other areas of the document from rendering.You can set this property only after the onload event fires on the window. When dynamically creating a tag using TextRange, IHTMLElement::innerHTML, or IHTMLElement::outerHTML, use Microsoft® JScript® (compatible with ECMA 262 language specification) to create new events to handle the newly formed tags. Microsoft® Visual Basic® Scripting Edition (VBScript) is not supported.You can change the value of the title element using the document.TITLE property.To change the contents of the TABLE, TFOOT, THEAD, and TR elements, use the table object model. For example, use the IHTMLTableRow::rowIndex property or the rows collection to retrieve a reference to a specific table row. To retrieve a reference to a specific cell, use the IHTMLTableCell::cellIndex property or the cells collection. You can add or delete rows using the IHTMLTableRow::insertCell and IHTMLTableRow::deleteCell methods. To change the content of a particular cell, use the IHTMLElement::innerHTML property.Property Information
      

  16.   

    简单啊!只要把两个“<”“>”之间的内容给踢了,就OK了啊!
    还有就是javascript和vbscript,只要把<script ...>和</script>之间的内容给删了。就万事大及了啊!
      

  17.   

    to shaker:
      很不错的建议,不过不具有通用性。
      要是正文中有一段<>挎起的内容怎么办?
      

  18.   

    在html文件中<>是&lt;&gt; 
    还有其他一些特殊字符,也是用这种方式纪录
    转为txt文件的时候,你要把它们替换回来
      

  19.   

    ExecWB cmdID,cmdExecept[,pvIn],[pvOut] 后面两个参数还没有琢磨过,反正可以把剪贴板的内容转到变量中并保存到一个文本文件中.
      

  20.   

    to ozw:
       你的意思是 <p>中的"<>"和  这是<文本>吗  中的"<>"不一样吗? 
      

  21.   

    想起一个简单的办法:
    text=webbrowser1.document.body.innertext
    open filetosave for binary as #1
    put #1,,text
    close #1
      

  22.   

    '这是我编的一个把网页中超级链接大小写混写转为大小或小写的源代码~!希望对你有用
    Public Function ProcessHtmlFile(FileName As String, LowOrUp As Boolean, ForceFileName As Boolean) As String
      '本段程序打开一个Html or Htm 文件后,写入另一个文件,删除原来的文件,并将临时文件改名为原来的文件
      On Error GoTo 100
      Dim TmpFileNumber As Integer
      Dim FileNumber As Integer
      Dim TextLine As String
      If Dir("c:\TmpFile.tmp") <> "" Then Kill "c:\TmpFile.tmp"
      TmpFileNumber = FreeFile '取得空文件号
      FileNumber = FreeFile '取得空文件号
      SetAttr FileName, vbArchive
      Open FileName For Input As FileNumber '打开原文件读出
      TmpFileNumber = FreeFile '取得空文件号
      Open "c:\tmpfile.tmp" For Output As TmpFileNumber '打开临时文件写入If LowOrUp Then
      
      Do While Not EOF(FileNumber)
      Line Input #FileNumber, TextLine
      TextLine = LProcessString(TextLine)
      Print #TmpFileNumber, TextLine
      Loop
      
      Close FileNumber '关闭全部打开的文件
      Close TmpFileNumber
      Kill FileName ' 删除原文件
      If ForceFileName Then
      Name "c:\tmpfile.tmp" As LCase(FileName)
      
      Else '将临时文件改名为原文件名
      
      Name "c:\tmpfile.tmp" As FileName
      
      End If
      
    Else
      
      Do While Not EOF(FileNumber)
      Line Input #FileNumber, TextLine
      TextLine = UProcessString(TextLine)
      Print #TmpFileNumber, TextLine
      Loop
      
      Close FileNumber '关闭全部打开的文件
      Close TmpFileNumber
      Kill FileName ' 删除原文件
      If ForceFileName Then
      Name "c:\tmpfile.tmp" As UCase(FileName)   '将临时文件改名为原文件名
      Else
      Name "c:\tmpfile.tmp" As FileName
      End If
      
    End If
    100
      If Err.Description = "" Or Err.Description = "无错误恢复" Then
      
      Else
      MsgBox Err.Description, vbOKOnly, "请检查你有没有打开和修改权限和读写磁盘权限"
      Resume Next
      End If
      
      
      
      End Function
    Public Function UProcessString(ByVal MyString As String) As String
    Dim I As Integer
    Dim TorN As Boolean
    Dim TmpString As String
    '定义临时变量和是否转换布尔值If IsScrip Then '如果要转换脚本文件
      
      For I = 1 To Len(MyString) '循环每一个字符
         
         If Mid(MyString, I, 1) = "<" Then
           TorN = True
         End If   '如果含有"<"则开始转换
         
         If Mid(MyString, I, 1) = ">" Then
           TorN = False
         End If '如果含有">"则停止转换
         
         If TorN Then
            TmpString = TmpString + UCase(Mid(MyString, I, 1)) '将变量转为大写
         Else
            TmpString = TmpString + Mid(MyString, I, 1)
         End If
      
      Next IElse
      
      For I = 1 To Len(MyString) '循环每一个字符
         
         If Mid(MyString, I, 1) = "<" Then
           TorN = True
           If LCase(Mid(MyString, I + 1, 6)) = "script" Or LCase(Mid(MyString, I + 1, 3)) = "!--" Then
           TorN = False
           'IsScrip = False
           'Debug.Print "I Found Start Sybol Scripting In The Web! No Proccess"
           End If
         End If '如果含有"<"则开始转换
         
         If Mid(MyString, I, 1) = ">" Then
           TorN = False
           'If LCase(Trim(MyString)) = "</script>" Or LCase(Trim(MyString)) = "//-->" Then
           'TorN = True
           'Debug.Print "I Found End Sybol Scripting In The Web! No Proccess"
           'End If
         End If '如果含有">"则停止转换
         
         If TorN Then
            TmpString = TmpString + UCase(Mid(MyString, I, 1)) '将变量转为大写
         Else
            TmpString = TmpString + Mid(MyString, I, 1)
         End If
      Next I
    End If
         
     
    UProcessString = TmpString ' 赋值给函数
    Debug.Print TmpString
    End Function
    Public Function LProcessString(ByVal MyString As String) As String
    Dim I As Integer
    Dim TorN As Boolean
    Dim TmpString As String
    '定义临时变量和是否转换布尔值
    For I = 1 To Len(MyString) '循环每一个字符
       
       If Mid(MyString, I, 1) = "<" Then
         TorN = True
       End If
       
       If Mid(MyString, I, 1) = ">" Then
         TorN = False
       End If
       
       If TorN Then
          TmpString = TmpString + LCase(Mid(MyString, I, 1)) '将变量转达为小写
       Else
          TmpString = TmpString + Mid(MyString, I, 1)
       End If
       
    Next ILProcessString = TmpString ' 赋值给函数End Function
    Public Function ProcessAllFile(FileName As String, LowOrUp As Boolean, ForceFileName As Boolean) As String
      
      Dim TmpFileNumber As Integer
      Dim FileNumber As Integer
      Dim TextLine As String
      On Error GoTo 100
      If Dir("c:\TmpFile.tmp") <> "" Then Kill "c:\TmpFile.tmp"
      TmpFileNumber = FreeFile '取得空文件号
      FileNumber = FreeFile '取得空文件号
      SetAttr FileName, vbArchive
      Open FileName For Input As FileNumber '打开原文件读出
      TmpFileNumber = FreeFile '取得空文件号
      Open "c:\tmpfile.tmp" For Output As TmpFileNumber '打开临时文件写入
      
      Do While Not EOF(FileNumber)
      Line Input #FileNumber, TextLine
      TextLine = ProcessAllString(TextLine, LowOrUp)
      Print #TmpFileNumber, TextLine
      Loop
      
      Close FileNumber '关闭全部打开的文件
      
      Close TmpFileNumber
      
      '本段应除文件的只读属性
      
      
      Kill FileName ' 删除原文件
      
      
      
      If ForceFileName Then
         
         Name "c:\tmpfile.tmp" As LCase(FileName)
         
         
         
      Else
      Name "c:\tmpfile.tmp" As FileName
      End If
      
    100
      If Err.Description = "" Or Err.Description = "无错误恢复" Then
      
      Else
      MsgBox Err.Description, vbOKOnly, "请检查你有没有打开和修改权限和读写磁盘权限"
      Resume Next
      End If
      End FunctionPublic Function ProcessAllString(ByVal MyString As String, LOU As Boolean) As String
    Dim I As Integer
    Dim TorN As Boolean
    Dim TmpString As String
    '定义临时变量和是否转换布尔值
    For I = 1 To Len(MyString) '循环每一个字符
       
       
       
       If LOU Then
          TmpString = TmpString + LCase(Mid(MyString, I, 1)) '将变量转为大写
       Else
          TmpString = TmpString + UCase(Mid(MyString, I, 1))
       End If
       
    Next IProcessAllString = TmpString ' 赋值给函数End Function
      

  23.   

    总算解决了!再次向对问题关心的各位表示感谢,特别感谢
    lou_df,事实上绕了一个大圈后,回到了我9-25的起点,
    只要用webbrower控件,再用webbrower1.navigate到所要的网页,然后由webbrowser1.document.body.innertext属性得出txt存入文件
    这就给分
      

  24.   

    新的问题:如果webbrower1.navigate后面紧跟webbrowser1.document.body.innertext的话,会出现错误。我试做将第二条语句放入事件:WebBrowser1_DocumentComplete()和WebBrowser1_DownloadComplete()中也不行。难道得用一个time来实现延时后再取得数据吗?又或者得用command_click()才能用第二条语句?不知道Cafes怎样解决这个问题的?
    [email protected]
      

  25.   

    WebBrowser1_DocumentComplete之后才能用webbrowser1.document.body.innertext获得文档
      

  26.   

    回楼上,发现在WebBrowser1_ProgressChange()里面加入RichTextBox1.Text = WebBrowser1.Document.body.innertext才能成功.在WebBrowser1_DocumentComplete()里加入还是不行.