Hello,
I just tried in my end and I can receive the right result with/without the "hypertext". But from my testing, "'" can not be translated correct to ('). You can use (') directly. Two things may help:
- The result shows only descriptions in the sample code
- You could set up the language with mkt = "en-US" in params
I am sharing my JSON result for your reference:
And also my code:
import json
import os
import requests
subscription_key = "****************************"
assert subscription_key
search_url = "https://api.bing.microsoft.com/v7.0/news/search"
search_term = "What Is Filecoin and Why Is the Cryptocurrency's Price Going Up?"
mkt = 'en-US'
headers = {"Ocp-Apim-Subscription-Key" : subscription_key}
params = {"q": search_term, "textDecorations": True, "textFormat": "HTML", 'mkt': mkt}
response = requests.get(search_url, headers=headers, params=params)
response.raise_for_status()
search_results = response.json()
descriptions = [article["description"] for article in search_results["value"]]
print(response.json())
from IPython.display import HTML
rows = "\n".join(["<tr><td>{0}</td></tr>".format(desc) for desc in descriptions])
HTML("<table>"+rows+"</table>")
Please let me know if you have any question.
Regards,
Yutong