From 454d3387dc23d5ce3102f53b7ccffdb01efdc19b Mon Sep 17 00:00:00 2001 From: NotoriousRebel Date: Sun, 23 Dec 2018 22:54:28 -0500 Subject: [PATCH] Fixing bingapi search and syncing. --- discovery/bingsearch.py | 15 +++++++++------ discovery/constants.py | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/discovery/bingsearch.py b/discovery/bingsearch.py index 610ce083..c7a49237 100644 --- a/discovery/bingsearch.py +++ b/discovery/bingsearch.py @@ -30,13 +30,16 @@ class search_bing: self.totalresults += self.results def do_search_api(self): - url = 'http://' + self.server + "/xml.aspx?Appid="+self.bingApi+"&query=%40" + \ - self.word + "&sources=web&web.count=40&web.offset=" + str(self.counter) - headers = { - 'Host': self.apiserver, - 'User-agent': getUserAgent() + url = 'https://api.cognitive.microsoft.com/bing/v7.0/search?' + params = { + 'q': self.word, + 'count': str(self.limit), + 'offset': '0', + 'mkt': 'en-us', + 'safesearch': 'Off' } - h = requests.get(url=url, headers=headers) + headers = {'User-Agent' : getUserAgent(), 'Ocp-Apim-Subscription-Key': self.bingApi} + h = requests.get(url=url, headers=headers, params=params) self.results = h.text self.totalresults += self.results diff --git a/discovery/constants.py b/discovery/constants.py index 431dfce5..4926338e 100644 --- a/discovery/constants.py +++ b/discovery/constants.py @@ -263,7 +263,7 @@ def filter(lst): lst = set(lst) # remove duplicates new_lst = [] for item in lst: - if (item[0].isalpha() or item[0].isdigit()) and not ('xxx' in item): + if (item[0].isalpha() or item[0].isdigit()) and ('xxx' not in item) and ('..' not in item): new_lst.append(item.lower()) return new_lst