I'm scraping a forum and extracting the post nodes, getting something like this:
nodes = page %>% html_nodes('.mypost')
nodes[[1]]
<div class="mypost" itemprop="text">
<div class="bbcode_container">
<div class="bbcode_quote">
<div class="quote_container">
<div class="bbcode_quote_container b-icon b-icon__ldquo-l--gray"></div>
<div class="bbcode_postedby">
Originally posted by <strong>Mike</strong>
</div>
<div class="message">
This is great news. Can you elaborate on what it means? \
</div>
</div>
</div>
</div>
I copied this from another web site. So I'm not sure...
</div>
I want to get all the text within the posts (in this case for node 1 the "I copied this...") but remove everything that is within the div class="bbcode_container".
Is there a way to remove children based on the class name? It's possible my node might have other div children with other names, and the position of bbcode_container is not fixed (could be anywhere, not at all, or appear multiple times so an xpath approach seems tricky at best).
I've seen there's a way to negate within rvest but I'm certain I'm doing it wrong:
nodes %>% html_nodes(':not(.bbcode_container)') %>% html_text()