Files
selmerBot/commands/misc/scraper.js
T

31 lines
1.1 KiB
JavaScript
Raw Normal View History

2022-04-30 21:45:03 -04:00
const hastebin = require("hastebin-gen");
2022-03-10 20:30:03 -05:00
module.exports ={
name: "scrape",
2022-03-10 20:30:03 -05:00
description: ".....",
async execute(message, args, Discord, Client, bot) {
2022-03-10 20:30:03 -05:00
const axios = require('axios');
const cheerio = require('cheerio');
2022-03-10 20:30:03 -05:00
const url = args[0];
axios(url)
2022-04-30 21:45:03 -04:00
.then(async response => {
2022-03-10 20:30:03 -05:00
const html = response.data;
const $ = cheerio.load(html);
2022-04-30 21:07:16 -04:00
//lyrics = $('.para_row').text();
2022-04-30 21:45:03 -04:00
const haste = await hastebin(html, { extension: "txt" });
message.channel.send(haste);
2022-04-30 21:09:16 -04:00
// console.log(lyrics);
2022-03-10 20:30:03 -05:00
})
.catch(function(err) {
if (err.message.indexOf('The "url" argument must be of type string') != -1) {
message.reply("The URL should be a string!");
} else {
message.reply("Oops! There's been an error");
}
console.log(err);
});
2022-03-10 20:30:03 -05:00
}
}
//TEST: https://www.karaoketexty.cz/texty-pisni/zoegirl/plain-170199