-3

我可以使用 C# 访问 HTML 表的数据吗?
我必须<td>从 C# 中获取 a 的 innerText (我不能使用其他任何东西)。
有简单的方法吗?也许使用SeleniumCoypu

4

2 回答 2

2

是的,使用硒

IList<IWebElement> TRCollection = driver.FindElement(By.Id("tableId")).FindElements(By.TagName("tr"));
IList<IWebElement> TDCollection;

foreach(IWebElement element in TRCollection )
{
//td list from each row
TDCollection = element.FindElements(By.TagName("td"));

string column1 = TDCollection[0].Text;
...
}
于 2016-06-28T13:30:24.573 回答
1

当我需要来自网页的任何数据时,我会使用 Html Agility Pack。这很方便,因为您会得到一个类似于 XmlDocument 的树,从而可以轻松地“遍历树”或执行任何类型的查询。

于 2016-06-28T13:30:36.960 回答