I am querying Bing News Search for foreign markets like China, Malaysia, Russia etc. The results are not always in English. Is there a way or a parameter I can set which would translate all results to English?
Or would I have to do this separately from the Bing News Search API by calling a different language translation API? The setLang parameter doesn't seem to work.
From the official documentation,
setLangshould not be used to set the language of search results. I checked the official documents. In 2012, Microsoft recommended usingJSON Code Sample (Web SourceType). I tested it and it didn't take effect. You can view related posts.Bing search API - How to localize results?
Because the existing materials are too old, they are all documents many years ago. So I recommend using Microsoft's
Translator.Below I provide sample code, replacing the values of
OcpApimSubscriptionKey1andOcpApimSubscriptionKey1andOcpApimSubscriptionRegion, which can be run directly. The effect diagram is as follows.Note:
1. The sample code provided is only a reference code, and it needs to take into account the processing of special characters when used in a production environment.
2. Sample code The non-optimal sample code is just my sample.