This project allows you to specify subreddits and then retrieve the most upvoted threads. It also includes a telegram bot so you can request the scrap through the app :D
You can use this project in three ways
- as a npm package, you will be able to use
getThreads
function. - as CLI command. Use
scrap-cli cats;brasil
. - as a Telegram bot, start it with
scrap-bot
.
CLI setup
- Clone the repo.
- Move to project's folder through a terminal.
- Run
npm install
. - Run
npm link
to allow commands. - Run
scrap-cli "askreddit;worlwide;cats"
. - You did it \o/
Telegram bot setup
- Clone the repo.
- Create a
.env
file into project's folder. - Put your bot token into
.env
file.- Eg.:
BOT_TOKEN=YOUR_BOT_TOKEN
- Eg.:
- Move to project's folder through a terminal.
- Run
npm install
. - Run
npm link
to allow commands. - Run
scrap-bot
to start the bot. - Now your bot should be running, go to telegram app and search for your bot.
- Start a conversation with it and type
/nadaprafazer askreddit;cats;worldwide
- Enjoy the results (:
Get your bot token: https://core.telegram.org/bots
NPM package
This project isn't registered on NPM registry so to try out getThreads
function you must use node console.
On a terminal, run
node
then
const getThreads = require("./index");
getThreads
function accepts four params:
- subreddit:
String
. - minScore:
Number
defaults to5000
. - period:
String
defaults to"day"
. - pageSize:
Number
defaults to25
.
You can run tests with npm test
.
You can lint the project with npm run lint
and npm run lint-fix
will fix most common mistakes while highlighting the ones that couldn't be fixed.
/bin/
- cli.js
- Implementation of reddit scraper CLI command.
- bot.js
- Implementation of reddit scraper telegram bot.
- cli.js
/src/
- get-threads.js
- Implementation of reddit scraper function.
- get-threads.js
/tests/
- fixtures folder and tests.
index.js
- Exports getThreads function.