简体   繁体   中英

How to search for old news data using Azure News Search Api

I am trying to fetch old news articles from 2018 using Azure News Search API.

I tried using datePublished, freshness, sortBy and since query parameters.

news_result = client.news.search(query=search_term, market="en-us", count=50, datePublished="2018-01-01T00:00:00")

first_news_result = news_result.value[0]
last_news_result = news_result.value[-1]

 print("news name: {}".format(first_news_result.name))
 print("news: {}".format(first_news_result.description))
 print("news name: {}".format(last_news_result.name))
 print("news: {}".format(last_news_result.description))

I was not able to get any article of a very old date. The oldest I got with

last_news_result = news_result.value[-1]

was like a month old.

What would be the solution to this?

Also, if its is not possible with Azure Api please suggest some where I can get old news.

Try using newsapi

 a = "https://newsapi.org/v2/everything?q={0}&from={1}&to={2}&sortBy=popularity&apiKey=".format(search_term, from_date, to_date)
 response = requests.get(a).json()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM