CKAN Filedownload with API

时间:2015-09-04 10:57:13

标签: python python-2.7 download ckan

我已经设置了一个带有所有必要插件的ckan-server。 服务器上有一些内容(.csv文件)。 现在我喜欢下载一个特定的.csv文件来在本地更改它并再次上传。

但我不知道如何使用ckan-API下载完整的文件。

有人能帮助我吗?

1 个答案:

答案 0 :(得分:0)

package_show API调用会告诉您CSV的网址,以便您下载。

e.g。这个数据集:http://data.gov.uk/dataset/uk-open-access-non-vosa-sites 可在API上找到:http://data.gov.uk/api/action/package_show?id=uk-open-access-non-vosa-sites 结果如下:

{
  "help": "http://data.gov.uk/api/3/action/help_show?name=package_show",
  "success": true,
  "result": 
  {
    "name": "uk-open-access-non-vosa-sites",
    "license_title": "UK Open Government Licence (OGL)",
    "resources": [
        {
            "description": "A list of Authorised Testing Facilities (ATFs) and DVSA test stations ",
            "format": "CSV",
            "url": "http://dft.gov.uk/vosa/images/Find%20your%20nearest%20ATF%20or%20VOSA%20test%20station.csv",
            "id": "bd9aaa9f-2a9c-45f8-8246-6b99dd78208a",
            "resource_type": "file",
        }
    ]
  }
}

您可以从中找到您可以下载的网址http://dft.gov.uk/vosa/images/Find%20your%20nearest%20ATF%20or%20VOSA%20test%20station.csv,例如使用wget:

wget http://dft.gov.uk/vosa/images/Find%20your%20nearest%20ATF%20or%20VOSA%20test%20station.csv