Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
yt-comment-scraper
Advanced tools
Scrapes the comments of any YouTube video without YouTube API access. Uses the default YouTube Ajax calls to get the comment data.
This NodeJS library scrapes the comments of the YouTube provided HTML comment data without any API usage order by date descending (so most recent first). It is developed for and tailored towards easy usage with FreeTube but can be used with any other project as well.
This library does not require any API keys, with the attached maximum quotas, but instead might take longer to receive the required data.
The library works as long as YouTube keeps its web page layout the same. Therefore, there is no guarantee that this library will work at all times. If this library should not work at some point, please create an issue and let me know so that I can take a look into it. Pull requests are also welcomed in this case.
npm install yt-comment-scraper --save
Set your instance with the following syntax. Use the second line instead if you're using modules / Typescript
const ytcm = require("yt-comment-scraper")
import ytcm from 'yt-comment-scraper'
getComments(payload)
Returns a list of objects containing comments from the next page of the video.
true
. Grabs top comments when false
const https = require('https');
const options = {...};
const agent = new https.Agent(options);
const payload = {
videoId: videoId, // Required
sortByNewest: sortByNewest,
continuation: continuation,
setCookie: false,
httpsAgent: agent
}
ytcm.getComments(payload).then((data) =>{
console.log(data);
}).catch((error)=>{
console.log(error);
});
Returned Data
The data is returned as a list of objects (seen below).
// The data is a list of objects containing the following attributes:
comments: [
{
commentId: String, // Id of comment
authorId: String, // Id of user that made the comment
author: String, // Name of the channel that made the comment
authorThumb: Array [ // An Array of thumbnails of the channel profile
{
width: Number,
height: Number,
url: String
}
],
edited: Boolean, // If the comment has been edited or not
text: String, // The text content of the comment
likes: String, // The amount of likes the comment has, numbers > 1000 displayed with 1.9K, 2K...
time: String, // The time the comment was published. Written as "One day ago"
numReplies: Number, // The number of replies found for the comment
isOwner: Boolean, // If the video channel made the comment
isHearted: Boolean, // If the video channel hearted the comment
isPinned: Boolean, // If the video channel pinned the comment
hasOwnerReplied: Boolean, // If the video channel replied to the comment
replyToken: String // The continuation token needed for getCommentReplies()
}],
continuation: String // The continuation token needed to get more comments from getComments()
getCommentReplies(payload)
Returns a list of objects containing replies from a given comment.
getComments()
or the continuation string from a previous call to getCommentReplies()
const parameters = {videoId: 'someId', replyToken: 'HSDcjasgdajwSdhAsd', setCookie: true, httpsAgent: null};
ytcm.getCommentReplies(parameters).then((data) =>{
console.log(data);
}).catch((error)=>{
console.log(error);
});
Returned Data
The data is returned as a list of objects (seen below).
// The data is a list of objects containing the following attributes:
comments: [
{
commentId: String, // Id of comment
authorId: String, // Id of user that made the comment
author: String, // Name of the channel that made the comment
authorThumb: Array [ // An Array of thumbnails of the channel profile
{
width: Number,
height: Number,
url: String
}
],
edited: Boolean, // If the comment has been edited or not
text: String, // The text content of the comment
likes: String, // The amount of likes the comment has, numbers > 1000 displayed with 1.9K, 2K...
time: String, // The time the comment was published. Written as "One day ago"
numReplies: Number, // The number of replies found for the comment
isOwner: Boolean, // If the video channel made the comment
isHearted: Boolean, // If the video channel hearted the comment
isPinned: false,
hasOwnerReplied: false,
replyToken: null
}],
continuation: String // The continuation token needed (instead of replyToken) to get more replies from getCommentReplies()
Thanks to egbertbouman for his/her Python project which guided this project through the difficult HTTP calls.
FAQs
Scrapes the comments of any YouTube video without YouTube API access. Uses the default YouTube Ajax calls to get the comment data.
The npm package yt-comment-scraper receives a total of 1 weekly downloads. As such, yt-comment-scraper popularity was classified as not popular.
We found that yt-comment-scraper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.