使用html敏捷包获取img src值

时间:2019-09-07 10:48:45

标签: c# html-agility-pack

我正在尝试从以下html获取img src图像链接的值。我已经像波纹管一样尝试了c#,但这无法获取链接。我在C#中做错了什么。有人可以帮助我吗?

C#:

Picture = htmlDoc.DocumentNode.SelectSingleNode("//div[@id='imgTagWrapperId']/img").Attributes["src"].Value;

HTML:

<div id="imgTagWrapperId" class="imgTagWrapper" style="height: 700px;">
                <img alt="PET N PET 1080 Counts Large Green Dog Waste Bags Unscented 60 Rolls Doggie Refill Bags" src="https://images-na.ssl-images-amazon.com/images/I/61xdgCf5UBL._SX679_.jpg" data-old-hires="https://images-na.ssl-images-amazon.com/images/I/61xdgCf5UBL._SL1001_.jpg" class="a-dynamic-image  a-stretch-vertical" id="landingImage" data-a-dynamic-image="{&quot;https://images-na.ssl-images-amazon.com/images/I/61xdgCf5UBL._SX466_.jpg&quot;:[466,466],&quot;https://images-na.ssl-images-amazon.com/images/I/61xdgCf5UBL._SX569_.jpg&quot;:[569,569],&quot;https://images-na.ssl-images-amazon.com/images/I/61xdgCf5UBL._SX425_.jpg&quot;:[425,425],&quot;https://images-na.ssl-images-amazon.com/images/I/61xdgCf5UBL._SY355_.jpg&quot;:[355,355],&quot;https://images-na.ssl-images-amazon.com/images/I/61xdgCf5UBL._SY450_.jpg&quot;:[450,450],&quot;https://images-na.ssl-images-amazon.com/images/I/61xdgCf5UBL._SX679_.jpg&quot;:[679,679],&quot;https://images-na.ssl-images-amazon.com/images/I/61xdgCf5UBL._SX522_.jpg&quot;:[522,522]}" style="max-width:679px;max-height:679px;">
            </div>

0 个答案:

没有答案