请告诉我如何从描述标签中获取图像。
描述标签位于
之下 <p style="text-align: center;"><img hspace="1" height="312" border="1" align="middle" width="300" vspace="3" src="/recipeuserfiles/Katte Pongali-andhra recipes-healthy recipes.PNG" alt="" /></p> <ul> <li>Mix the rice and Green gram dal Cook in pressure cooker and keep it side. </li> <li>Now take a vessel and heat the ghee and add add pepper, cumin seeds, curry leaves and cashew nuts to it. </li> <li>Then add the cokked rice and dal , salt and mix it properly. </li> <li>Delicious pongali is ready to taste. Have it with any of your favorite chutney.</li> </ul>
任何帮助都将不胜感激。
提前致谢
答案 0 :(得分:0)
您可以使用HtmlAgilityPack轻松地从HTML中提取信息。例如:
var html = @"<p style=""text-align: center;""><img hspace=""1"" height=""312"" border=""1"" align=""middle"" width=""300"" vspace=""3"" src=""/recipeuserfiles/Katte Pongali-andhra recipes-healthy recipes.PNG"" alt="""" /></p> <ul> <li>Mix the rice and Green gram dal Cook in pressure cooker and keep it side. </li> <li>Now take a vessel and heat the ghee and add add pepper, cumin seeds, curry leaves and cashew nuts to it. </li> <li>Then add the cokked rice and dal , salt and mix it properly. </li> <li>Delicious pongali is ready to taste. Have it with any of your favorite chutney.</li> </ul>";
var doc = new HtmlDocument();
doc.LoadHtml(html);
var src = doc.DocumentNode.SelectSingleNode("//img").GetAttributeValue("src", "");
//this will print /recipeuserfiles/Katte Pongali-andhra recipes-healthy recipes.PNG
Console.WriteLine(src);
网上有很多关于如何安装HAP和开始使用的文章/教程,你可以随时搜索它。