已知道在某一张网页中存在一个IFRAME,如何取得这个IFRAME的SRC属性以及这个IFRAME内的网页源代码及网页中所有图片的地址?谢谢

解决方案 »

  1.   

    转到WEB版去吧,不然……
    呵呵
      

  2.   

    '引用internet control控件
    '引用html object对象
    Private Sub Form_Load()
        Dim html As New HTMLDocument
        Dim i As Integer
        ie.Navigate "d:\3.htm"
        Set html = ie.Document
        For i = 0 To html.frames.length - 1
            GetImagSrc html.frames(i).Document
        Next
    End Sub
    Private Sub GetImagSrc(doc As Object)
        Dim i As Integer
        Dim frmhtml As HTMLDocument
        Set frmhtml = doc
        Debug.Print frmhtml.location
        For i = 0 To frmhtml.images.length - 1
            Debug.Print frmhtml.images(i).src
        Next
    End Sub
    网页3.htm
    <html><head>
    <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>New Page 2</title>
    </head><frameset rows="64,*">
      <frame name="header" scrolling="no" noresize target="main" src="1.htm">
      <frame name="main" src="2.htm">
      <noframes>
      <body>  <p>此网页使用了框架,但您的浏览器不支持框架。</p>  </body>
      </noframes>
    </frameset></html>'网页2的内容
    <a href = 'http://www.sina.com.cn'>sina</a>
    <img border="0" src="1.bmp"></p>
    <img border="0" src ="2.bmp">
      

  3.   

    不是FRAME标签,是IFRAME标签。
      

  4.   

    不是FRAME标签,是IFRAME标签。
      

  5.   

    '不好意思昨天说错了,iframe还是用frames,程序如下
    Private Sub Form_Load()
        Dim html As New HTMLDocument
        Dim i As Integer
        ie.Navigate "d:\1.htm"
        Set html = ie.Document
        For i = 0 To html.frames.length - 1
            GetImagSrc html.frames(i).Document
        Next
    End Sub
    Private Sub GetImagSrc(doc As Object)
        Dim i As Integer
        Dim frmhtml As HTMLDocument
        Set frmhtml = doc
        Debug.Print frmhtml.location
        For i = 0 To frmhtml.images.length - 1
            Debug.Print frmhtml.images(i).src
        Next
    End Sub1.htm内容
    <IFRAME SRC="frame.htm" STYLE="z-index:1" >
    </IFRAME>
    frame.htm内容
    <img border='0' src='1.bmp'>
    <p>
    <img border ='0' src = '2.bmp'>
    '输出结果
    file:///D:/frame.htm
    file:///D:/1.bmp
    file:///D:/2.bmp
      

  6.   

    如果将1.htm改成:<IFRAME SRC="http://www.sohu.com/" STYLE="z-index:1" >
    </IFRAME>这样就不可以了,你试试,它提示:实时错误'-2147024891 (80070005)';
    拒绝访问好像IE不允许这样的跨域操作。
      

  7.   

    这个我也没办法了,得到所有内容,自己
    去里面检测吧,str=ie.document.body.innerhtml
      

  8.   

    暂找到不种不太好的办法,在网页加载成功事件中(每一个框架网页和主页面的成功载入都会触发一次此事件),捕捉到此DOCUMENT保存到全局变量中,以后用就可以了。