'Is there any way to scrape YouTube comments by specific keywords?
I want to scrape YouTube comments but only those which have a particular keyword in them. And that keyword will be set by me. For example, if I only want comments with the word "password" in them. So, can I do something like that?
I am scraping using Google Spreadsheets Apps Script. I have managed to scrape all comments, with and without replies.
Solution 1:[1]
Try something like this:
let wantedComments = [];
let keyword = "keyword"
let re = new RegExp(`${keyword}`,'g');
commentslist.forEach(c => {
if(c.match(r)) {
wantedComments.push(c)
}
});
Presumably you will be getting a list from the youtube api in the form of an array. So loop through it a run it through the loop to only capture the ones with you keyword.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Cooper |
