我用winform做了一个框架 里面有一个axWebBrowser ,加载是自已做的本地网页,我需要从网页取得一些数值,不知道该如何取!!

解决方案 »

  1.   

    请参阅 WebBrowser.Document 属性
      

  2.   

    //Get the request from the web server(s)
    HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(m_sURLToProcess);
    WebResponse myResponse = myReq.GetResponse();

    //Get the data from the stream
    int iContentLength;
    ArrayList sTotalBuffer = new ArrayList(); if (myResponse.ContentLength >= 0)
    {
    //*********************  Take care of if the Content Length can be found (if the string can be seeked)
    iContentLength = (int)myResponse.ContentLength;
    }
    else
    {
    //*********************  Take care of if the Content Length cannot be found (if the string can't be seeked)
    iContentLength = 1024;
    } BinaryReader br = new BinaryReader(myResponse.GetResponseStream());
    int iTotalBytes = 0;

    m_iBytesRead = 1;
    iTotalBytes = 0;
    while (m_iBytesRead > 0)
    {
    byte[] sBuffer = new byte[iContentLength];
    m_iBytesRead = br.Read(sBuffer, 0, iContentLength);
    if (m_iBytesRead > 0)
    {
    for(int i=0;i<m_iBytesRead;i++)
    {
    sTotalBuffer.Add(sBuffer[i]); 
    }
    iTotalBytes += (int)m_iBytesRead;
    }


    byte[] sTmp=new byte[sTotalBuffer.Count];
    sTotalBuffer.CopyTo(sTmp);

             string sTmpHTML;
    sTmpHTML = System.Text.Encoding.GetEncoding("GB2312").GetString(sTmp);
    再分析sTmpHTML 中的内容就可以了
      

  3.   

    直接建立个txt文件或者数据库文件,把web需要传递的值写进去,然后在winform里读出来
    哈哈.菜鸟的方法
      

  4.   

    使用Microsoft.mshtml库可以访问浏览器控件中的dhtml对象,
    using mshtml;
    ... HTMLDocument htmlDocument = (HTMLDocument)axWebBrowser1.Document;
    if (htmlDocument != null)
    {
    HTMLInputElement btnSubmit = (HTMLInputElement)htmlDocument.all.item("btnSubmit", 0);
    if (btnSubmit != null)
    btnSubmit.click();
    }