gpt4 book ai didi

javascript - 从 The Guardian API 获取文章文本

转载 作者:行者123 更新时间:2023-12-02 06:31:45 25 4
gpt4 key购买 nike

我在从 The Guardian 的新闻 API 获取文章文本时遇到问题。我有一个类似这样的网址:http://content.guardianapis.com/search?section=technology&api-key=MYKEY
我得到的回复如下所示:

{
"response": {
"status": "ok",
"userTier": "developer",
"total": 54530,
"startIndex": 1,
"pageSize": 10,
"currentPage": 1,
"pages": 5453,
"orderBy": "newest",
"results": [{
"type": "article",
"sectionId": "technology",
"webTitle": "Net neutrality has its day in court – with lawyers, Christians and the Cheshire Cat",
"webPublicationDate": "2015-12-05T12:30:06Z",
"id": "technology/2015/dec/05/net-neutrality-has-its-day-in-court-with-lawyers-christians-and-the-cheshire-cat",
"webUrl": "http://www.theguardian.com/technology/2015/dec/05/net-neutrality-has-its-day-in-court-with-lawyers-christians-and-the-cheshire-cat",
"apiUrl": "http://content.guardianapis.com/technology/2015/dec/05/net-neutrality-has-its-day-in-court-with-lawyers-christians-and-the-cheshire-cat",
"sectionName": "Technology"
}, {
"type": "article",
"sectionId": "technology",
"webTitle": "Five things we love: from a school-proof tablet to a ghostly Serbian bicycle",
"webPublicationDate": "2015-12-05T10:00:02Z",
"id": "technology/2015/dec/05/five-things-we-love",
"webUrl": "http://www.theguardian.com/technology/2015/dec/05/five-things-we-love",
"apiUrl": "http://content.guardianapis.com/technology/2015/dec/05/five-things-we-love",
"sectionName": "Technology"
}, {
"type": "article",
"sectionId": "technology",
"webTitle": "Don’t listen to those who try to own the definition of a video game",
"webPublicationDate": "2015-12-04T12:00:21Z",
"id": "technology/2015/dec/04/video-games-gaming-dudegamers",
"webUrl": "http://www.theguardian.com/technology/2015/dec/04/video-games-gaming-dudegamers",
"apiUrl": "http://content.guardianapis.com/technology/2015/dec/04/video-games-gaming-dudegamers",
"sectionName": "Technology"
}]
}
}

这不包括文章文本,只包括新闻页面的网址。 我的问题是如何获取文章文本?

最佳答案

尝试添加 show-blocks=all&查询,例如。归还的属性(property)"bodyTextSummary"在网址。下面的 URL 可以分解为:
基本网址: http://content.guardianapis.com/search? 搜索参数的开始: q= 搜索参数(所有“”都替换为“%20”): 12%20years%20a%20slave& 转成json格式: format=json& 按特定标签过滤: tag=film/film,tone/reviews& 按开始日期过滤: from-date=2010-01-01& 按相关性排序: order-by=relevance& 显示完整的 API 哈希: show-blocks=all& 您的 API key (应该将您的 key 放在“测试”的位置): api-key=test
http://content.guardianapis.com/search?q=12%20years%20a%20slave&format=json&tag=film/film,tone/reviews&from-date=2010-01-01&order-by=relevance&show-blocks=all&api-key=test

http://open-platform.theguardian.com/documentation/search

关于javascript - 从 The Guardian API 获取文章文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34108030/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com