From bd80c42bed3d4bf9ab65909582d6a9ecc29efe47 Mon Sep 17 00:00:00 2001 From: ION606 Date: Sat, 30 Apr 2022 21:45:03 -0400 Subject: [PATCH] Finished fixing the web-scraper for Heroku --- commands/scraper.js | 10 ++++++---- package-lock.json | 17 +++++++++++++++++ package.json | 1 + 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/commands/scraper.js b/commands/scraper.js index 7b778c1..8ac68c7 100644 --- a/commands/scraper.js +++ b/commands/scraper.js @@ -1,17 +1,19 @@ +const hastebin = require("hastebin-gen"); + module.exports ={ name: "scraper", description: ".....", - execute(message, args) { + async execute(message, args) { const axios = require('axios'); const cheerio = require('cheerio') const url = args[0]; axios(url) - .then(response => { + .then(async response => { const html = response.data; const $ = cheerio.load(html); //lyrics = $('.para_row').text(); - - message.channel.send(html); + const haste = await hastebin(html, { extension: "txt" }); + message.channel.send(haste); // console.log(lyrics); }) .catch(console.error); diff --git a/package-lock.json b/package-lock.json index dadcb9b..9eb81ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "discord.js": "^13.6.0", "ffmpeg": "^0.0.4", "ffmpeg-static": "^5.0.0", + "hastebin-gen": "^2.0.5", "libsodium-wrappers": "^0.7.10", "node.js": "^0.0.1-security", "play-dl": "^1.9.4", @@ -924,6 +925,14 @@ "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" }, + "node_modules/hastebin-gen": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/hastebin-gen/-/hastebin-gen-2.0.5.tgz", + "integrity": "sha512-At1LaKtcqh2jiP8xfE2sDGT9IshIki6FqsgLwn2y7FzAvlFJRtpUsSPh3yWjWIQIvxi/GPF07IBqSI8WhPL/gQ==", + "dependencies": { + "node-fetch": "^2.6.0" + } + }, "node_modules/htmlparser2": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz", @@ -2925,6 +2934,14 @@ "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" }, + "hastebin-gen": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/hastebin-gen/-/hastebin-gen-2.0.5.tgz", + "integrity": "sha512-At1LaKtcqh2jiP8xfE2sDGT9IshIki6FqsgLwn2y7FzAvlFJRtpUsSPh3yWjWIQIvxi/GPF07IBqSI8WhPL/gQ==", + "requires": { + "node-fetch": "^2.6.0" + } + }, "htmlparser2": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz", diff --git a/package.json b/package.json index d99bbdd..5cd7363 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "discord.js": "^13.6.0", "ffmpeg": "^0.0.4", "ffmpeg-static": "^5.0.0", + "hastebin-gen": "^2.0.5", "libsodium-wrappers": "^0.7.10", "node.js": "^0.0.1-security", "play-dl": "^1.9.4",