以示例中的 vbulletin 站点为例。我希望能够只从线程中抓取短信。然而,消息的 css 选择器被称为 #post_message_xxx ,其中 xxx 是一个变量 id 号。
如何将选择器与 html_nodes 部分匹配,以便获得所有以 #post_message 开头的选择器,而不管它们如何结束?
或者我应该问一个更笼统的问题。如果我希望能够将作者归因于消息并跟踪消息顺序,我应该如何抓取页面。
谢谢。
library(rvest)
html <- html("http://www.acme.com/forums/new_rules_28429/")
cast <- html_nodes(html, "#post_message_28429")
cast
> <div id="post_message_28429"> Thanks for posting
> this. </div>
>
> attr(,"class")
[1] "XMLNodeSet"