<a class="product-name" href="http:xyz" title="Polac pineapple slices 3kg">Polac pineapple slices 3kg</a> <div class="price-box"> <span class="regular-price" id="product-price-5489"> <span class="price">Rs 665</span> </span>
如果一个HTML标签匹配,则另一标签应使用htmlagilitypack
我想从跨度标签得到的价格被抓取,但是匹配时,它应该提供特定项目的价格。就像如果一个标签有内部文本Polac菠萝那么它应该返回665卢比以下 代码是我使用
`
var aTags = document.DocumentNode.SelectNodes("//a");
var nextTags = document.DocumentNode.SelectNodes("//span");
if (aTags != null)
{
foreach (var aTag in aTags)
{
s += counter + ". " + aTag.InnerText + "<br>";
//s += aTag.InnerText;
if (aTag.InnerText == "Polac pineapple")
{
brandcheck = true;
find += aTag.InnerText + " ";
foreach (var nextTag in nextTags)
{
//s += counter + ". " + nextTag.InnerText + "<br>";
s += nextTag.InnerText;
if (nextTag.InnerText.Contains("Rs"))
{
brandcheck = true;
find = nextTag.InnerText + " ";
}
}`
你可以添加你的示例代码 – ChrisBint
@ChrisBint签出,我已经添加了代码! –