zoukankan      html  css  js  c++  java
  • 利用webBrowser获取页面iframe中的内容

    1.获取frame的document

      HtmlDocument htmlDoc = webBrowser1.Document;
      htmlDoc = webBrowser1.Document.Window.Frames["frmRpt"].Document;

      "frmRpt"为iframe的name;

    2.获取frame的源文件

    MessageBox.Show(webBrowser1.Document.Window.Frames["main"].Document.Body.InnerHtml);

    3.获取frame的HTMLDocument接口

    HTMLDocument doc = (HTMLDocument)webBrowser1.Document.DomDocument;
    object j;
    for (int i = 0; i < doc.parentWindow.frames.length; i++)
    {
           j = i;
           HTMLWindow2Class frame = doc.parentWindow.frames.item(ref j) as HTMLWindow2Class;
           if (frame.name == "main")
            {                   
                  MessageBox.Show(frame.document.title);                    
            }
    }     

    4.获取frame的IHTMLDocument2接口

    IHTMLDocument2 doc = (IHTMLDocument2)webBrowser1.Document.Window.Frames["main"].Document.DomDocument;

    5.取得frame中被点击的连接

    private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
    {
          string url = webBrowser1.Document.Window.Frames["main"].Document.ActiveElement.GetAttribute("src");
    }

  • 相关阅读:
    Sql优化思路
    「网络流随想随记」
    「ZJOI 的部分题解整理」
    「循环矩阵相关的一些东西」
    知识蒸馏
    3D Human Pose Estimation with 2D Marginal Heatmaps
    模型剪枝
    目标检测小网络
    selenium---解决clear方法失效
    selenium---快速跳转到指定元素
  • 原文地址:https://www.cnblogs.com/qqhfeng/p/8672371.html
Copyright © 2011-2022 走看看