Random user agents for google and rotten tomatoes

This commit is contained in:
Dragon Fire
2021-03-18 17:08:12 -04:00
parent 4f8330886b
commit a1bbaed04b
3 changed files with 6 additions and 2 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const cheerio = require('cheerio');
const UserAgent = require('user-agents');
const { URLSearchParams, URL } = require('url');
module.exports = class GoogleCommand extends Command {
@@ -57,7 +58,7 @@ module.exports = class GoogleCommand extends Command {
filter: 0,
q: query
})
.set({ 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1' });
.set({ 'User-Agent': new UserAgent().toString() });
const $ = cheerio.load(text);
const links = [];
$('body').find('h3').each((i, h3) => {
+3 -1
View File
@@ -1,6 +1,7 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const request = require('node-superfetch');
const UserAgent = require('user-agents');
const { shorten } = require('../../util/Util');
module.exports = class RottenTomatoesCommand extends Command {
@@ -57,7 +58,8 @@ module.exports = class RottenTomatoesCommand extends Command {
.query({
limit: 10,
q: query
});
})
.set({ 'User-Agent': new UserAgent().toString() });
if (!body.movies.length) return null;
const find = body.movies.find(m => m.name.toLowerCase() === query.toLowerCase()) || body.movies[0];
return find.url.replace('/m/', '');
+1
View File
@@ -74,6 +74,7 @@
"tesseract.js": "^2.1.4",
"text-diff": "^1.0.1",
"tictactoe-minimax-ai": "^1.2.1",
"user-agents": "^1.0.594",
"valid-url": "^1.0.9",
"winston": "^3.3.3",
"ytdl-core": "^4.5.0"