From 9cc81a7df091dcf2e1e1cd59272b5eb765ef483b Mon Sep 17 00:00:00 2001 From: Adriene Hutchins Date: Tue, 24 Mar 2020 22:57:54 -0400 Subject: [PATCH] Feexed scrapeing --- extensions/search.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/extensions/search.py b/extensions/search.py index 3d20280..1668ed3 100644 --- a/extensions/search.py +++ b/extensions/search.py @@ -10,6 +10,7 @@ from discord.ext import commands from typing import List from extensions.models import SearchExceptions import html2text +from urllib.parse import quote_plus import re @@ -71,15 +72,6 @@ class Search(commands.Cog, name="Basic"): if any(n in query for n in nono_words): raise SearchExceptions.SafesearchFail('Query had NSFW.') - # Scrape or not - # if self.scrape_token != '': - # base = ( - # "http://api.scrapestack.com/scrape" - # f"?access_key={self.scrape_token}" - # f"&url=https://api.qwant.com/api" - # ) - # print(base) - # else: base = "https://api.qwant.com/api" # Safesearch @@ -99,6 +91,15 @@ class Search(commands.Cog, name="Basic"): "&locale=en_US" "&uiv=4" ) + + # Scrape or not + if self.scrape_token != '': + search_url = ( + "http://api.scrapestack.com/scrape" + f"?access_key={self.scrape_token}" + f"&url={quote_plus(search_url)}" + ) + await self.debug(search_url, name="_search_logic") # Searching @@ -242,8 +243,6 @@ class Search(commands.Cog, name="Basic"): "we cannot accept in a non-NSFW channel. " "Please try again in an NSFW channel." ) - except Exception as e: - print(e) def setup(bot):