用StreamReader对象读取html文本,再用StreamWriter对象输出成文本文件就行了

解决方案 »

  1.   

    我只想要html里面的文本,楼上的这个做法html的格式符号都全部带着了!
      

  2.   

    你可以用正则表达式替换掉啊:
    Regex.Replace(strValue,@"<[^<>]*>","");
      

  3.   

    Regex.Replace(strValue,@"<[^<>]*>","");
      

  4.   

    //引用 Microsoft HTML Object Library
    //引用 Microsoft 浏览器
    //这个是重网站上取(需要等一会)
    private void button1_Click(object sender, System.EventArgs e)
    {
    axWebBrowser1.Navigate("Http://www.csdn.net");
    button1.Enabled=false;
    while (axWebBrowser1.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
    {
    //WebBrowser1 读取是异步的
    Application.DoEvents();
    System.Threading.Thread.Sleep(10);

    }
    mshtml.IHTMLDocument2 doc = axWebBrowser1.Document as mshtml.IHTMLDocument2;
    if (doc !=null)
    {
    if (doc.body!=null)
    {
    string s = doc.body.innerText;
    if (s!=null && s.Length >0)
    {
    MessageBox.Show(s);

    }
    }
    }
    button1.Enabled=true;
    }
    //下面的是重你自己已经有的 html 里取
    private static string HtmlText(AxSHDocVw.AxWebBrowser Wb,string HtmlStr)
    {
    Wb.Navigate("about:blank");
    while (Wb.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
    {
    Application.DoEvents();
    }
    Application.DoEvents();
    mshtml.IHTMLDocument2 doc = Wb.Document as mshtml.IHTMLDocument2;
    doc.close();
    doc.write(HtmlStr);
    return  doc.body.innerText;
    }
    private void button2_Click(object sender, System.EventArgs e)
    {

    MessageBox.Show(HtmlText(axWebBrowser1,"<Html>哈哈哈哈<html>"));

    }
      

  5.   

    是啊,用 AxWebBrowser 控件可以实现的,就是楼上说的那样。