@benh666/core
v1.1.1
Published
A scraper made in Node.js
Maintainers
Readme
@benh666/core
A lightweight, modular Node.js SDK built with pure ESM for scraping and extracting metadata/media from platforms like SoundCloud and YouTube. It handles dynamic authentication and session management automatically under the hood.
Features
- SoundCloud Extractor: Automatically fetches dynamic
client_idtokens without requiring official API keys. - Smart Caching: In-memory and disk persistence for auth tokens with automatic TTL management.
- API Instance with Interceptors: Built on
kyfor fast, reliable HTTP requests. - TypeScript Support: Includes
.d.tstype definitions for API responses and method auto-completion. - 100% ESM: Native support for modern Node.js environments.
Installation
Install the package via npm:
npm install @benh666/coreUsage/Examples
import { scrapers } from '@benh666/core';
const soundcloud = await scrapers.soundcloud;
//search collection tracks | albums | playlists
const response = await soundcloud.search({queue: "Pyramid song", limit: 20, offset: 0, app_locale: "en", typeSearch: "tracks"});
const json = response.json
const results = json.collection.pop()
console.log(results.title) // 01 Pyramid Song
console.log(results.created_at) // 2017-02-12T04:41:26ZNOTE: YouTube scraper only get a list of videos, track only get a metadata but not audio/video stream.
import { scrapers } from '@benh666/core';
const youtube = await scrapers.youtube;
//search list of videos
const response = await youtube.search({
queue: "Pyramid song", hl: 'en', gl: 'US'});
const json = response.json
const results = json.results[0]
console.log(results.title) // Radiohead - Pyramid Song
console.log(results.id) // 3M_Gg1xAHE4
// track a song
// You can provide an ID or one search
const track = await youtube.track({ queue: "Pyramid Song" });
const trackedSong = track.json
console.log(trackedSong.channel) // Radiohead
console.log(trackedSong.url) // https://www.youtube.com/watch?v=3M_Gg1xAHE4
CNV Scraper (YouTube Download / Instagram / TikTok)
import { scrapers } from '@benh666/core';
const cnv = await scrapers.cnv;
// Download YouTube video
const videoResponse = await cnv.youtube({
url: "https://www.youtube.com/watch?v=xxxxxxxxxxx",
type: "video",
quality: 720
});
console.log(videoResponse.title); // Video title
console.log(videoResponse.server_path); // Download URL
// Download YouTube audio
const audioResponse = await cnv.youtube({
url: "https://www.youtube.com/watch?v=xxxxxxxxxxx",
type: "audio",
quality: "320kbs"
});
console.log(audioResponse.title); // Audio title
// Fetch Instagram Reels or TikTok videos
const fetchResponse = await cnv.fetch({
url: "https://www.instagram.com/reel/xxxxxxxxx/"
});
console.log(fetchResponse.status); // "true"
console.log(fetchResponse.url); // Download URL
const tiktokResponse = await cnv.fetch({
url: "https://www.tiktok.com/@user/video/xxxxxxxxxxxxxx"
});
console.log(tiktokResponse.filename); // Video filenameTwitter/X Scraper
import { scrapers } from '@benh666/core';
const twitter = await scrapers.twitter;
// Using v1 API (x-downloader)
const v1Response = await twitter.v1({
url: "https://x.com/user/status/xxxxxxxxxxxxxx"
});
console.log(v1Response.json.title); // Tweet title
console.log(v1Response.json.formats); // Available formats
// Using v2 API (twitterdownload page)
const v2Response = await twitter.v2({
url: "https://x.com/user/status/xxxxxxxxxxxxxx"
});
console.log(v2Response.highest_resolution); // Highest quality URL
console.log(v2Response.description); // Tweet description