当前位置:  开发笔记 > 编程语言 > 正文

从Guardian API获取文章文本

如何解决《从GuardianAPI获取文章文本》经验,为你挑选了1个好方法。

我从"卫报"的新闻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"
    }]
}
}

并且不包括文章文本,只包含新闻页面的网址.我的问题是如何获得文章文本?



1> 小智..:

尝试添加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://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=测试


请参见http://open-platform.theguardian.com/documentation/search

推荐阅读
php
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有