title: Scraping Youtube comments in R
body: <p>I'm extracting user comments from a range of websites (like reddit.com) and Youtube is also another juicy source of information for me. My existing scraper is written in R:</p>
  
  <pre><code># x is the url
  html = getURL(x)
  doc  = htmlParse(html, asText=TRUE) 
  txt  = xpathSApply(doc, 
     //body//text()[not(ancestor::script)][not(ancestor::style)][not(ancestor::noscript)]",xmlValue) 
  </code></pre>
  
  <p>This doesn't work on Youtube data, in fact if you look at the source of a Youtube video like <a href="https://www.youtube.com/all_comments?v=t-Ux1pdlOT0">this</a> for example, you'd find that comments do not appear in the source.</p>
  
  <p>Does anyone have any suggestions on how to extract data in such circumstances?</p>
  
  <p>Many thanks!</p>