假设我在下面运行代码:
url.df_1 = htmlTreeParse(url_1, useInternalNodes = T)
并得到以下 htmlTree :
<!-- ******************* related ******************* -->
<div class="more-related-box">
<div id="app_related">
<h3>Customers Also Bought</h3>
<ul>
<li><a href="/app/ios/flick-golf/" title="Flick Golf!"><img src="http://a2.mzstatic.com/us/r1000/067/Purple/v4/25/a8/91/25a891df-fed4-9dc4-0d86-1c8f5acf893f/mzl.fcctkywr.75x75-65.jpg" class="app_icon"><span class="app_name">Flick Golf!</span><span class="category">Games</span></a></li>
<li><a href="/app/ios/minecraft-pocket-edition/" title="Minecraft – Pocket Edition"><img src="http://a1.mzstatic.com/us/r1000/070/Purple2/v4/3f/56/07/3f56074b-af27-8ba3-7ef8-c97314c13ee7/mzl.rfhcaysw.75x75-65.jpg" class="app_icon"><span class="app_name">Minecraft – Pocket Edition</span><span class="category">Games</span></a></li>
我想从上面抓取的是“flick-golf”和“minecraft-pocket-edition”。(所以上面是 htmltree 的一部分,我想获取这些名称并希望最终将它们作为列表或数据框。)
到目前为止,我尝试了这个(以及其他一些)
getNodeSet(url.df_1, "//div[@id = 'app_related']//h3 ")
但我最终得到
[[1]]
<h3>Customers Also Bought</h3>
attr(,"class")
有什么建议吗?谢谢!