纽约时报API和NYT python库

时间:2016-10-14 21:18:58

标签: python

我试图通过web_url库在Python上检索参数newyorktimes。但是,python上的查询结果比NYT API的结果要小。

这是我的代码:

from nytimesarticle import articleAPI

api = articleAPI("*Your Key*")
articles = api.search( q = 'terrorist attack')

print(articles['response'],['docs'],['web_url'])

2 个答案:

答案 0 :(得分:0)

你缺少分页,试试这个:

articles = api.search( q = 'terrorist attack', page=1)

现在您可以继续增加page并获得更多文章。礼貌地称为RTFM nytimesarticle

答案 1 :(得分:0)

尝试 @GET("{duration}.json") Call<MostPopularData> getMostPopularArticles(@Path("duration") int duration, @Query("api-key") String apiKey, @Query("offset") int offset);

偏移量必须为正且为20的倍数。

相关问题