尝试使用html agility pack获取此处服务数量的值
<span class="recipe-ingredients__header__toggles">
<span class="ready-in-time__container">
<span class="ready-in-time">3 h 30 m</span>
<span class="icon--stats-clock"></span>
</span>
<meta id="metaRecipeServings" itemprop="recipeYield" content="8">
<a href="" id="servings-button" popup-trigger="servingsSection">
<span class="servings-count" ng-class="{'active': servingsSection_showing}"><span ng-bind="adjustedServings" class="ng-binding">8</span><span class="servings-count__desc" ng-class="{'active': servingsSection_showing}"> servings</span></span>
<span class="icon--adjust-servings" ng-class="{'active': servingsSection_showing}"></span>
</a>
<a href="" id="nutrition-button" popup-trigger="nutritionSection">
<span class="calorie-count" ng-class="{'active': nutritionSection_showing}"><span>562</span> <span class="calorie-count__desc" ng-class="{'active': nutritionSection_showing}"> cals</span></span>
<span class="icon--nutrition-info" ng-class="{'active': nutritionSection_showing}"></span>
</a>
具体来说,我正在看标签
<span ng-bind="adjustedServings">
具有值&#34; 8&#34;。我在这里得到了所有其他价值,但似乎无法想出这一点。在这种情况下,我只想要整数8。
答案 0 :(得分:1)
SelectSingleNode("//span[@ng-bind='adjustedServings']").InnerText
应该做的伎俩。如果您有多个这些span
使用SelectNodes
,请在foreach
中使用它并分别访问节点上的InnerText
。
没有尝试编译,如果您遇到错误,我会对其进行编辑