using mshtml; /// <summary>
/// Returns a reference to the frame window with an given index in the top level document of the Webbrowser control
/// </summary>
/// <param name="frameIndex">zero-based index that specifies the index of the frame window</param>
        [CLSCompliant(false)]
        public IHTMLWindow2 GetFrameByIndex(int frameIndex)
        {
            IHTMLDocument2 htmlDocument = (IHTMLDocument2)this.Document.DomDocument;
            return GetFrameByIndex(frameIndex, htmlDocument);
        }
/// <summary>
/// Returns a reference to the frame window with an given index in an HTML document
/// </summary>
/// <param name="frameIndex">zero-based index that specifies the index of the frame window</param>
/// <param name="htmlDocument">the HTML document to search in</param>
[CLSCompliant(false), ComVisible(false)]
static public IHTMLWindow2 GetFrameByIndex(int frameIndex, IHTMLDocument2 htmlDocument)
        {
if (htmlDocument == null)
return null;
            object oIndex = frameIndex;
            object oFrame=htmlDocument.frames.item(ref oIndex);
            if (oFrame== null) return null;
            return (IHTMLWindow2)oFrame;
        }

解决方案 »

  1.   

    点击这个javascript:top.et.Openet(185) 就会转到链接http://……/…….asp?185,然后怎么抓取这个数据保存呢?还有180,165数字不固定,每天更新,如何才能每天能自动分析这个数字,然后抓取这些页面上的数据保存呢?
      

  2.   

    我也用这个的,但对于这个网站好像单独用httpwebrequest 取不到数据
      

  3.   

    read the javascript code and rewrite the function in C#.
      

  4.   

    function Displaynums(numsSource, VolumeSource) {
      var nums = document.getElementsByName('nums');
      var Volume = document.getElementsByName('Volume');
      if (numsSource.length == nums.length) {
        for (i=0;i<numsSource.length;i++) {
          
          if (numsSource[i] == '0') {
            nums[i].innerHTML = '&nbsp;';     //!!!这里得nums[i]就是我要获得的数据
            Volume[i].innerHTML = '&nbsp;'; }
          else {
    /*
            // Change et colors
            if (nums[i].innerHTML != '' && Volume[i].innerHTML != '' && (nums[i].innerHTML != numsSource[i] || Volume[i].innerHTML != VolumeSource[i])) {
              nums[i].style.color='#FFFFFF';
              Volume[i].style.color='#FFFFFF';
              }
    */
            nums[i].innerHTML = numsSource[i];
            Volume[i].innerHTML = VolumeSource[i];
          }
        }
      }
      else {
        window.location.reload(); 
      }
    }这段代码我读出来了,我要得到得就是nums[i]这些数据 请问如何取的这些数据,小弟非常感谢~!
      

  5.   

    上面搞错了,应该是numsSource[i]为我需要获的数据。
      

  6.   

    jiangcheng 高手请帮一下啊,怎么在客户端调用服务器端的java 函数,实在想不出办法了
      

  7.   

    call the same DOM method
    HtmlWindow PopupOptionWindow()
    { IHTMLAnchorElement ae = extendedWebBrowser1.GetLinkByHref("popupEligiNewRT");
    if (ae != null)
    {
    Debug.WriteLine(ae.href);
    //javascript:popupEligiNewRT('DIANA%20JOHN%20W',%20'SUB','form0') //function popupEligiNewRT(name,opt,form){
    // var str = "eligipopup.jsp?&name="+name+"&opt="+opt+"&form="+form;
    // window.open(str, 'popupeligiwin', 'width=600,height=375,left=250,top=100,menubar=yes,status=yes,toolbar=no');
    //}
    string href = ae.href;
    href = href.Substring(
    href.IndexOf("("));
    String delim = "()";
    href = href.Trim(delim.ToCharArray());
    string[] parameters = href.Split(",".ToCharArray());
    delim = "'";
    string name = parameters[0].Trim(delim.ToCharArray());
    string opt = parameters[1].Trim(delim.ToCharArray());
    string form = parameters[2].Trim(delim.ToCharArray());
    string PopupURL = string.Format("https://www.example.com/eligipopup.jsp?&name={0}&opt={1}&form={2}", name, opt, form);
    return extendedWebBrowser1.Document.Window.Open(PopupURL, "autopopupeligiwin", "width=600,height=375,left=250,top=100,menubar=yes,status=yes,toolbar=no", false);
    }
    return null;
    }