I'm trying to use the Bing image search API for a small Python script I'm making. I want to simply search a term in Japanese or Chinese, such as 生姜 and get at least the first image result. My code works fine with English queries and it returns multiple values in the thumbnail_urls list. I have made sure that mkt and set_lang strings are properly assigned. I have also made sure that search_term is not an empty string. I am certain that my subscription key is working, since the code returns results for English. Is there something I am doing wrong when I specify the language such that I get no returned thumbnail urls? Here is the function I am trying to use:
def get_image(search_term, lang):
if lang == "zh-TW-YunJheNeural":
mkt = "zh-TW"
set_lang = "zh-hant"
else:
mkt = "ja-JP"
set_lang = "jp"
headers = {"Ocp-Apim-Subscription-Key" : IMAGE_KEY}
params = {"q": search_term, "license": "public", "imageType": "photo", "mkt": mkt, "setLang": set_lang}
response = requests.get(SEARCH_URL, headers=headers, params=params)
search_results = response.json()
thumbnail_urls = [img["thumbnailUrl"] for img in search_results["value"][:16]]
print(thumbnail_urls)
