Fixing bingapi search and syncing.

This commit is contained in:
NotoriousRebel 2018-12-23 22:54:28 -05:00
parent d0b49f87e2
commit 454d3387dc
2 changed files with 10 additions and 7 deletions

View file

@ -30,13 +30,16 @@ def do_search(self):
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

View file

@ -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