Scraping YouTube comments

Home Forum GSERM-2020 Scraping YouTube comments

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #106
    rammy
    Participant

    Hi everyone,
    I would please like to know if anyone has suggestions or resources for scraping YouTube comments. Thank you in advance!

    Best regards,
    Rammy

    #108
    hofstett
    Keymaster

    Rammy

    We played around with this actually yesterday, too. Have a look at this code, it reads the number of comments. Reading the comments should be relatively straightforward from there.

    Best, Reto

    library('RSelenium')
    
    rD <- rsDriver(port = 4447L, browser = c("firefox"))
    
    #chrome
    #rD <- rsDriver(port = 4449L, browser = c("chrome"), chromever = "83.0.4103.39")
    
    remDr <- rD[["client"]]
    
    remDr$navigate("https://www.youtube.com/watch?v=7WfoYl-EPtI")
    print(remDr$getCurrentUrl())
    
    webpage <- read_html(remDr$getPageSource()[[1]])
    remDr$screenshot(display = TRUE)
    
    html_text(html_nodes(webpage, ".count-text.style-scope.ytd-comments-header-renderer"))
    #111
    rammy
    Participant

    Hi Reto,
    Thanks for your reply! I actually looked into this code, but I was getting an error, which I now realize is because I was missing a package. I will review this portion and play around some more. Thanks again!

    Best regards,
    Rammy

    • This reply was modified 4 months, 3 weeks ago by rammy.
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.