Skip to content

Instantly share code, notes, and snippets.

@theabbie
Created September 13, 2020 20:51
Show Gist options
  • Select an option

  • Save theabbie/c9d813b57a12bb9a8e2b5adddeb873f7 to your computer and use it in GitHub Desktop.

Select an option

Save theabbie/c9d813b57a12bb9a8e2b5adddeb873f7 to your computer and use it in GitHub Desktop.
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