Skip to content

Instantly share code, notes, and snippets.

@theabbie

theabbie/index.js

Created Sep 13, 2020
Embed
What would you like to do?
Devrant Rant Generator
var app = require('express')();
var axios = require("axios");
var cheerio = require("cheerio");
var mkvtext = require("theabbie").text;
app.get("/*", async function(req,res) {
var $ = cheerio.load((await axios("https://devrant.com/search?term="+req.query.id)).data);
var data = $('.rantlist-title-text').map((i,el)=>$(el).text()).get().join(" ").toLowerCase().replace(/[^a-zA-Z0-9\s\:]*/g,"").replace(/\r\n/g, '\n').replace(/\t+/g,"").split('\n').filter(x => /\w/.test(x)).join(' ');
res.end(mkvtext(200,data));
})
app.listen(process.env.PORT);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment