【问题标题】:'object' does not contain a definition for 'innerHTML'“object”不包含“innerHTML”的定义
【发布时间】:2014-09-09 18:50:15
【问题描述】:

我正在使用 c# mshtml 从网站获取 html 数据。

public mshtml.HTMLTableRow tr = default(mshtml.HTMLTableRow);

//do some stuff

tr.cells.item(0).innerHTML

它将“项目”识别为通用对象。这曾经有效,但现在出现此错误。

【问题讨论】:

    标签: c# html automation mshtml


    【解决方案1】:

    我不知道这是否是你想要的,但如果你想从网站上下载完整的 html,你可以这样做:

    using System.Net;
    //...
    using (WebClient client = new WebClient ()) // WebClient class inherits IDisposable
    {
        client.DownloadFile("http://yoursite.com/page.html", @"C:\localfile.html");
    
        // Or you can get the file content without saving it:
        string htmlCode = client.DownloadString("http://yoursite.com/page.html");
    }
    

    然后,如果您想要代码的某个部分,您可以使用该字符串。希望对你有帮助!!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-30
      • 2016-01-24
      • 1970-01-01
      • 2021-11-29
      • 2018-05-28
      • 2020-12-31
      • 2012-09-10
      • 1970-01-01
      相关资源
      最近更新 更多