title: R: rvest: How to use ifelse for nodes?
body: <p>I'm scrapping this page:</p>
  
  <p><a href="https://www.linio.com.pe/c/tv-y-video/televisores" rel="nofollow noreferrer">https://www.linio.com.pe/c/tv-y-video/televisores</a></p>
  
  <p>And I want to extract the current price of the TVs. The problem is that some prices are inside a <code>&lt;div&gt;</code> and others -fewer- inside a <code>&lt;span&gt;</code> tag.</p>
  
  <p>I'm wondering if it's possible to use an 'ifelse' construct to get all the current prices for the TVs.</p>
  
  <pre><code>#Reads Linio's HTML
  
  linio &lt;- read_html("https://www.linio.com.pe/c/tv-y-video/televisores", encoding = "ISO-8859-1")
  
  
  #Extracts prices inside the div tag
  
  
  linio %&gt;% html_nodes("div.price-section div.price-secondary") %&gt;% html_text()
  
  
  #Extracts prices inside the span tag
  
  linio %&gt;% html_nodes("div.price-section span.price-secondary") %&gt;% html_text()
  </code></pre>
  
  <p>I was trying this to combine the prices from the div and the span tags:</p>
  
  <pre><code>linio %&gt;% ifelse(length(html_nodes("div.price-section div.price-secondary") %&gt;% html_text())==0, html_nodes("div.price-section span.price-secondary") %&gt;% html_text(), html_nodes("div.price-section div.price-secondary")) %&gt;% html_text()
  </code></pre>
  
  <p>Without success... why can't you be consistant Linio's front end developers...!</p>