0
我正在使用Bing Web Search API來獲取與特定查詢匹配的URL。不幸的是,API結果中也有很多垃圾。Bing Web Search API和黑名單(python)
現在我創建了一個廣泛的黑名單,這個「垃圾」的70%。
什麼是最有效的方法來排除URL列表被附加到我的「結果」數組?
代碼的有趣的部分:
results = []
try:
conn = http.client.HTTPSConnection('api.cognitive.microsoft.com')
conn.request("GET", "/bing/v5.0/search?%s" % params, "{body}", headers)
response = conn.getresponse()
data = response.read()
json_file = json.loads(data)
for i in range(len(json_file['webPages']['value'])):
results.append([count, json_file['webPages']['value'][i]['displayUrl']])
conn.close()
except Exception as e:
print(e)
這真的取決於您的黑名單的工作方式。 –