Rea*_*iez 2 javascript api object
我从"卫报"的新闻API中获取文章文本时遇到问题.我有一个这样的网址:http://content.guardianapis.com/search?section = technology &api-key = MYYEY ,我收到的响应如下:
{
"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"
}]
}
}
Run Code Online (Sandbox Code Playgroud)
并且不包括文章文本,只包含新闻页面的网址.我的问题是如何获得文章文本?
尝试添加show-blocks=all&查询,例如."bodyTextSummary"在url 返回属性.下面的网址可以细分为:
基本URL: http://content.guardianapis.com/search?
开始搜索PARAMS的: q=
搜索PARAMS(全""被替换为"%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密钥(应该将您的密钥放在"test"的位置): api-key=test
请参见http://open-platform.theguardian.com/documentation/search
对您的 URL使用show-fields键和bodyText键值,然后您将获得内容。
例如:show-fields=BodyText
http://content.guardianapis.com/search?order-by=newest&show-fields=bodyText&q=politics&api-key=test