【发布时间】:2016-04-04 13:50:22
【问题描述】:
我正在编写一个程序,其中string 我有一个HTML 页面 的代码。现在,我需要获取<article> 标记之间的文本。我的html页面包含多个article标签,所以我需要获取不同article标签的文本
文章标签的一个例子是:
<article class="item" data-recipe="119726">
<a class="loopimg pvideo" href="http://www.cookaround.com/ricetta/pasta-frolla-4.html" title="Leggi: Pasta frolla"><img src="http://cdn.cook.stbm.it/thumbnails/ricette/119/119726/hd400x225.jpg" alt="Leggi: Pasta frolla" /></a>
<h3><a href="http://www.cookaround.com/ricetta/pasta-frolla-4.html" title="Leggi: Pasta frolla">Pasta frolla</a></h3>
<ul><li>Difficoltà <span>bassa</span></li><li class="costo">Costo <span>basso</span></li><li>Realizzazione <span>10 min</span></li></ul>
</article>
所以,我需要获取每个文章标签的title="Leggi: Pasta frolla",其中title对于每个标签都是不同的。
如何使用 c++ 做到这一点?
【问题讨论】:
-
你试过
std::string::find和std::string::substring吗? -
但是对于多个文章标签?我的文章标签数量未定义@NathanOliver
-
将查找作为while循环的条件。
-
@NathanOliver 怎么样?哪个变量?
标签: html c++ tags html-parsing html-parser