Can I get Bing custom search results utilizing only blocked pages?

203 views Asked by At

In my Bing custom search engine, I have an empty active list, and I have a few sites on my blocked list. I want to see ALL web results minus my blocked list, but I'm getting zero results this way. Is there a way I can do this?

EDIT: RESOLVED. SEE CODE BELOW Note: I used the Bing Web Search API in favor of the custom search to achieve me desired results.

# code solution, I was able to get my desired results and
# exclude a large number of websites with this method
# I can confirm that at least 20 stacked exclusions are working with no issues.

def bing_search(key,url,term):
    headers = {"Ocp-Apim-Subscription-Key" : subscription_key}
    params  = {"q": bterm, "textDecorations":True, "textFormat":"HTML"}
    response = requests.get(search_url, headers=headers, params=params)
    response.raise_for_status()
    search_results = response.json()




results = bing_search(subscription_key, search_url, (str(each) +
                                                             "-site:facebook.com "
                                                             "-site:yellowpages.com "
                                                             "-site:yelp.com "
                                                             "-site:local.yahoo.com "
                                                             "-site:manta.com "
                                                             "-site:searchonamerica.com "
                                                             "-site:wellness.com "
                                                             "-site:countyoffice.org "
                                                             "-site:buzzfile.com "
                                                             "-site:superpages.com "
                                                             "-site:dandb.com "
                                                             "-site:finduslocal.com "
                                                             "-site:chamberofcommerce.com "
                                                             "-site:whitepages.com "
                                                             "-site:businessfinder.nola.com "
                                                             "-site:yellowbook.com "
                                                             "-site:bizapedia.com "
                                                             "-site:bbb.org "
                                                             "-site:mapquest.com "
                                                             "-site:infofree.com "))

I hope that the custom search engine will allow this functionality in the future.

1

There are 1 answers

0
Ronak On BEST ANSWER

You can use the Bing web search api, if the list of blocked sites is small. You can use the -site:www.xyz.com as a query parameter. Here is the link to the API: https://azure.microsoft.com/en-us/services/cognitive-services/bing-web-search-api/.