我有一个html文件如下:
<h3>
<div id='type'>
Type 1
</div>
<div id='price'>
127.76;
</div>
</h3>
<h3>
<div id='type'>
Type 2
</div>
<div id='price'>
127.76;
</div>
</h3>
现在我想使用 CSQuery 将这些类型和价格提取到一个列表中,这是我正在处理的代码:
var doc = CQ.Create(htmlfile);
var types= (from listR in doc["<h3>"] //get the h3 tag
select new TypeTest
{
Typename = listR.GetAttribute("#type"),
Price = listR.GetAttribute("#price")
}
).ToList();
return types;
但是,我无法如愿获得详细信息,因为当我将其设置为 h3 时,我不确定 doc[] 的值。无法修改 html 文件。