我访问了NYT API。
我最初使用的是http调用:https://api.nytimes.com/svc/search/v2/articlesearch.json?fq=source:("The New York Times")AND pub_date:("2019-04-04")&api-key=<MY KEY HERE>
。
这让我对本节有一个 json:
"meta": {
"hits": 176,
"offset": 0,
"time": 8
}
然后,我使用以下调用循环浏览每个点击或页面:https://api.nytimes.com/svc/search/v2/articlesearch.json?fq=source:("The New York Times")AND pub_date:("2019-04-04") AND page=<EACH NUMBER> &api-key=<MY KEY HERE>
。
但是,当我应该得到 70+ 时,我只收到 150 篇文章。我在电话中做错了什么?
如果将 API 调用更改为以下内容,这将起作用:
articlesearch.json?fq=source:"The New York Times"&sort=newest&begin_date=20190404&end_date=20190404&page=0
...
articlesearch.json?fq=source:"The New York Times"&sort=newest&begin_date=20190404&end_date=20190404&page=21