How to solve the problem that Bing API returns error code 500 when performing domain name filtering retrieval

feiyang lu 0 Reputation points
2024-01-20T12:44:37.96+00:00

When I try to search and filter certain domain names using the bing api, I find that once I add the filter information, the server returns an unknown error with error code 500,The following is an example of retrieval code, please tell me the cause and solution of the error, thank you very much

response = requests.post('http://127.0.0.1:7907/bing_search', 
headers = {'Content-Type': 'application/json'}
, json={"query": ["Pachira Aquatica including the following aspects: taxonomy and naming, description"],
    "-domain": "wikipedia.org,wikiwand.com,wiki2.org,wikimedia.org"}
)
Bing Web Search
Bing Web Search
A Bing service that gives you enhanced search details from billions of web documents.
128 questions
{count} votes

1 answer

Sort by: Most helpful
  1. romungi-MSFT 42,191 Reputation points Microsoft Employee
    2024-01-22T09:57:33.43+00:00

    @feiyang lu I see you are using a local host setup to call Bing API. I am not sure how this is setup to call the actual Bing search API but to limit the responses to a certain domain or website, you will have to use the site operator in your query parameter. Here is an example of your request. User's image

    As you can see, the site operator uses the following pattern: "query text":site="site1","site2" You should also ensure your query does not have an intermediate ":" since that might be causing to read the text after ":" as an operator instead. Please see the reference for full details on how to use the operators with query parameter. I hope this helps!!

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    0 comments No comments