2017-07-06 35 views
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) 
+0

这真的取决于您的黑名单的工作方式。 –

回答