This package has been deprecated and no longer works.
Command line utility for scraping YouTube comments.
If you prefer a simple-to-use online solution, please go to http://ytcomments.klostermann.ca.
npm install -g youtube-comment-scraper-cli
youtube-comment-scraper <VideoID>
youtube-comment-scraper --help
$ youtube-comment-scraper [options] <VideoID>
For more detailed instructions suitable for beginners take a look at the NetLab Tutorial.
It's part of the video URL: https://www.youtube.com/watch?v=<VideoID>
.
Examples:
Video URL | Video ID |
---|---|
https://www.youtube.com/watch?v=abc123def45 | abc123def12 |
https://youtu.be/abc123def45 | abc123def45 |
All command line options are optional (d'oh), except for the VideoID parameter.
Option | Description |
---|---|
-f --format <format> |
output format (json or csv) |
-o --outputFile <outputFile> |
write results to the given file |
-d --stdout |
write results to stdout |
-c --collapseReplies |
collapse replies and treat them the same as regular comments |
-s --stream |
output comments one-at-a-time as they are being scraped |
-V, --version |
output the version number |
-h, --help |
output usage information |
-f --format <format>
The comments can be formatted as either JSON or CSV data. Defaults to JSON if not specified.
youtube-comment-scraper -f csv <VideoID>
youtube-comment-scraper --format json <VideoID>
-o --outputFile <outputFile>
The comments can be written directly to a file. In that case they will not be written to stdout (the terminal window). If you want both file and stdout output use the --stdout
flag in addition to --outputFile
.
youtube-comment-scraper -o ./path/to/some/file.json <VideoID>
youtube-comment-scraper --outputFile some-file.csv --stdout --format csv <VideoID>
-d --stdout
By default comments are always written to stdout (even without the --stdout
flag). However, when using --outputFile
, they will only be written to the file. If you want output to both, use --stdout
.
youtube-comment-scraper -d <VideoID>
youtube-comment-scraper --outputFile ./some/file --stdout <VideoID>
-c --collapseReplies
By default replies to comments are kept nested under that comment. If --collapseReplies
is set, replies will be treated the same as regular comments. An additional field is added to replies replyTo
wich contains the ID of the comment to which a reply belongs.
youtube-comment-scraper -c <VideoID>
youtube-comment-scraper --collapseReplies --format csv <VideoID>
-s --stream
By default the program will scrape all comments without outputting any of them until the scrape is complete. When the --stream
flag is set, comments are written one at a time as soon as they are scraped, while still maintaining the original order of comments (newest first). This works for both the JSON and CSV format.
youtube-comment-scraper -s <VideoID>
youtube-comment-scraper --stream --format csv <VideoID>
youtube-comment-scraper --stream --format csv --outputFile some-file.csv <VideoID>
youtube-comment-scraper --stream <VideoID> > json-processing-tool
-V --version
Output the current version of the program.
youtube-comment-scraper -V
youtube-comment-scraper --version
-h --help
Output usage help.
youtube-comment-scraper -h
youtube-comment-scraper --help