'object'不包含'innerHTML'的定义

时间:2021-09-12 16:57:53

I'm using c# mshtml to get html data from a website.

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

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

//do some stuff

tr.cells.item(0).innerHTML

it is recognizing "item" as a generic object. This used to work but now it is giving this error.

它将“item”识别为通用对象。这曾经工作,但现在它给出了这个错误。

1 个解决方案

#1


1  

I don't know if it is what you want, but if you want to donwload the FULL html from a website, you can do it this way:

我不知道这是不是你想要的,但是如果你想从网站上下载完整的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");
}

Then you can work with the string if you want a certain part of the code. Hope it helps!!

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

#1


1  

I don't know if it is what you want, but if you want to donwload the FULL html from a website, you can do it this way:

我不知道这是不是你想要的,但是如果你想从网站上下载完整的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");
}

Then you can work with the string if you want a certain part of the code. Hope it helps!!

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