积极答复者
关于mshtml.HTMLDocument获取网页中框架内的源码

问题
-
<html>
<head>
<META http-equiv=Content-Type content="text/html; charset=gbk">
<title>XXX公司生产运营监管系统</title>
</head>
<frameset rows=75,* cols="*" frameborder="no" bordercolor="#CCCCCC" name="aaa">
<frame src="top.jsp" noResize scrolling=no target="contents" name="banner">
<frameset id="bottommain" rows="*" cols=192,14,* bordercolor="#FFFFFF" framespacing="0" frameborder="no" border="0" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" >
<frame src="treemenu.html?method=listTreeMenu" target="main" name="contents" border="0" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<frame src="middle.htm" name="mid" scrolling="NO" border="0" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<frame src="测试1.html?method=list&first=1&timeType=50" name="main" border="0" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
</frameset><noframes>
<body>
<p>
此网页使用了框架,但您的浏览器不支持框架?
</p>
</body>
</noframes>
</frameset>
</html>网页的代码如上。我想获取框架中的“测试1.html”网页的源代码里的一个“summonpwr169“元素 应该怎么实现。
name1=”summonpwr169“
Dim sws As New SHDocVw.ShellWindows Dim ie As SHDocVw.InternetExplorer For Each ie In sws Dim doc1 As mshtml.HTMLDocument doc1 = TryCast(ie.Document, mshtml.HTMLDocument) If Not doc1 Is Nothing Then If InStr(doc1.body.innerHTML, name1) <> 0 Then doc1.body.all("" & name1 & "").value = doc1.body.all("" & name1 & "").value + rlt1 doc1.body.all("" & name2 & "").value = doc1.body.all("" & name2 & "").value + rlt2 doc1.body.all("" & name3 & "").value = doc1.body.all("" & name3 & "").value + rlt3 MsgBox("程序运行成功,请核对。", MsgBoxStyle.Information, "完成") End If End If Next
答案
-
问题解决了 没人理我 自己google 了
http://www.mndsoft.com/Blog/VB6/0435.html 研究了下这里的代码最后得出了结果。
代码如下:
Dim X As Object
X = doc1.frames.document.frames
msgbox (X(3).document.body.innerHTML) '读取第三个框架的的HTML代码X(3).document.body.all("" & name1 & "").value = X(3).document.body.all("" & name1 & "").value + rlt1
'累加的作用。- 已标记为答案 ChiYauModerator 2011年6月13日 20:18
全部回复
-
问题解决了 没人理我 自己google 了
http://www.mndsoft.com/Blog/VB6/0435.html 研究了下这里的代码最后得出了结果。
代码如下:
Dim X As Object
X = doc1.frames.document.frames
msgbox (X(3).document.body.innerHTML) '读取第三个框架的的HTML代码X(3).document.body.all("" & name1 & "").value = X(3).document.body.all("" & name1 & "").value + rlt1
'累加的作用。- 已标记为答案 ChiYauModerator 2011年6月13日 20:18