see WalkAll Sample in Web Workshop
解决方案 »
- VBA 中全局数据的使用方法
- access中类型为数字类型的要如何查询
- 为什么我有一个工程RUN的时候,窗体在编译器后面,而别的程序没有这个问题?
- 文件-打开工程 对话框里的"最新"里的 程序名和路径存放在哪个文件里?
- 在代码中如何使用SQL的脚本建库?
- 请各位大侠多多指点
- 还是关于打印机走纸问题,都一个星期多了,这儿还是没人会解答,要崩溃了 :(
- 用VB+ADO+DBF做服务器/客户程序,我见过,但不知道具体怎么做,不知有人知道否?
- 如何将一个文件夹完全共享,用代码,完成给分
- 删除问题2
- 难道很难吗?【【【【有个动态二维数组,我如何知道第一维和第二维有多少个元素?】】】】
- 一个有关vbscript的问题
她之存下HTML文件的标题呀!
如果说你真这样做,
几天后,我帮你做一个试试,OK!
没有见过从HTML转化成TXT。
能具体一点吗,有没有 例程?
......不好意思,我没学过vc
只要告诉我是在vb的工程中加入什么库的调用
以及相关的对象属性
只要告诉我是在vb的工程中加入什么库的调用
以及相关的对象属性
这个Ihtmldocument接口在哪儿?
有创意的,又要去enumwindow了
不过我想应该有简便的方法
可以用navigate方法打开指定页面了
不过还不知道如何保存页面,其中document属性一项不知怎么用,有高手提点一下吗
先 selectall
然后 copy
最后 paste
有点小问题,ExecWB cmdID,cmdExecept[,pvIn],[pvOut]
后三个参数怎么用?
是在pvout 中指定输出的文件名吧?pvin是什么?
cmdID不用saveas可以吗?
OLECMDEXECOPT_DONTPROMPTUSER, "c:\c.htm", "c:\c.htm" 就将控件中显示的页面保存到 c:\c.htm
但我执行时是会调出 saveas 对话框的,怎么才能不经过确认这一步?
使用
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
还有就是javascript和vbscript,只要把<script ...>和</script>之间的内容给删了。就万事大及了啊!
很不错的建议,不过不具有通用性。
要是正文中有一段<>挎起的内容怎么办?
还有其他一些特殊字符,也是用这种方式纪录
转为txt文件的时候,你要把它们替换回来
你的意思是 <p>中的"<>"和 这是<文本>吗 中的"<>"不一样吗?
text=webbrowser1.document.body.innertext
open filetosave for binary as #1
put #1,,text
close #1
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
lou_df,事实上绕了一个大圈后,回到了我9-25的起点,
只要用webbrower控件,再用webbrower1.navigate到所要的网页,然后由webbrowser1.document.body.innertext属性得出txt存入文件
这就给分
[email protected]