重要

翻译是一项社区工作:ref:你可以加入<translation_guidelines>。此页面目前翻译进度为 45.99%。

24.1.4. File tools

24.1.4.1. Download file via HTTP(S)

Downloads a URL to the file system with an HTTP(S) GET or POST request.

参数

Basic parameters

标注

名称

类型

描述

URL

URL

[string]

The URL of the file to download.

File destination

OUTPUT

[string]

默认: [保存到临时文件]

Specification of the file destination. One of:

  • 保存到临时文件

  • 保存到文件…

Advanced parameters

标注

名称

类型

描述

Method

METHOD

[enumeration]

Default: 0

The HTTP method to use for the request. Options are:

  • 0 --- GET

  • 1 --- POST

Data

可选

DATA

[string]

The data to add in the body if the request is a POST.

输出

标注

名称

类型

描述

File destination

OUTPUT

[string]

The location of the downloaded file

Python代码

Algorithm ID: qgis:filedownloader

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。

24.1.4.2. HTTP(S) POST/GET request

Performs a HTTP(S) POST/GET request and returns the HTTP status code and the reply data. If an error occurs then the error code and the message will be returned. Optionally, the result can be written to a file on the disk. By default the algorithm will warn on errors. Optionally, the algorithm can be set to treat HTTP errors as failures.

参数

标注

名称

类型

描述

URL or file path

URL

[string]

The URL or path of the file to open.

Method

METHOD

[enumeration]

Default: 0

The HTTP method to use for the request. Options are:

  • 0 --- GET

  • 1 --- POST

POST Data

可选

DATA

[string]

The data to add in the body if the request is a POST.

Authentication

可选

AUTH_CONFIG

[authconfig]

Default: No authentication

An authentication configuration to pass

Consider HTTP errors as failures

FAIL_ON_ERROR

[boolean]

Default: False

If set, the algorithm will fail on encountering an HTTP error.

File destination

可选

OUTPUT

[string]

Default: [Skip Output]

The result can be written to a file instead of being returned as a string. Specification of the file destination. One of:

  • Skip Output

  • 保存到临时文件

  • 保存到文件…

输出

标注

名称

类型

描述

File destination

OUTPUT

[file]

The downloaded file with the returned result

HTTP Status

STATUS_CODE

[string]

The HTTP Status

Network error code

ERROR_CODE

[string]

The error code when it fails (like as well on 404 HTTP Status etc.)

Network error message

ERROR_MESSAGE

[string]

A string containing the error message in case of failure

Result data

RESULT_DATA

[string]

A string containing the result data in case of success

Python代码

Algorithm ID: native:httprequest

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。

24.1.4.3. Open file or URL

Opens files in their default associated application, or URLs in the user's default web browser.

参数

标注

名称

类型

描述

URL or file path

URL

[string]

The URL or path of the file to open.

输出

The algorithm has no output.

Python代码

Algorithm ID: native:openurl

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。