我开始使用R,有一个问题,我想收集一个html页面的价格列表。这是一个例子,当我问R的价格时,我能得到什么
<h3 class="item_price" itemprop="price" content="16450"> 16 450 ⬠</h3>
我知道下面有35个价格 <h3 class="item_price" itemprop="price" content="1234"> 是否可以过滤h3元素和属性class=“item\u price”,然后请求内容属性值?
<h3 class="item_price" itemprop="price" content="1234">
是的,这是可能的-源:rvest::html\u attr文档
movie <- read_html("http://www.imdb.com/title/tt1490017/") cast <- html_nodes(movie, "#titleCast span.itemprop") html_text(cast) html_name(cast) html_attrs(cast) html_attr(cast, "class")