纽约时报API和NYT python库

2024-09-28 03:22:30 发布

您现在位置:Python中文网/ 问答频道 /正文

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

这是我的代码:

from nytimesarticle import articleAPI

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

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

Tags: key代码fromimportapiweburlsearch
2条回答

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

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

缺少分页,请尝试以下操作:

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

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

相关问题 更多 >

    热门问题