网页截图API接口

电脑如何实现长截屏?网页页面截图截图工具中用户只要输入想要截图的网页地址就可以保存该网页的截图,而且保存的图片大小为网页的实际大小,一键网页抓图专门截图的软件。

接口文档 《查看会员》
接口地址: http://api.toolfk.com/api/captures | 在线体验接口
请求方法: [ "GET", "POST" ]
请求参数:
名称 类型 描述 示例
token string 请求的token 用户中心获取token
url string 需要截图的网站链接 https://www.baidu.com
format string 保存的格式(.png,.pdf) .png
visit string 1:PC页面,2:手机页面 1
ratio string 手机页面时的分辨率(0:1920x1080,1:2560x1440,2:1680x1050,3:1440x900,4:1280x1024,5:1024x768) 0
-- 漂亮的分割符 --
返回数据:

{
    "status": 1,
    "data": {
        "fullpath": "http://www.toolfk.com/storage/tmp/c62b9f58d5877af2475886946ba0e65a.png",
        "filename": "c62b9f58d5877af2475886946ba0e65a.png",
        "link": "https://www.baidu.com",
        "format": ".png"
    }
}
                
                            
代码示例:
  • Curl
  • PHP
  • Java
  • Python
  • JavaScript
  • Go
  • Nodejs

    curl -X POST \
    http://api.toolfk.com/api/captures \
    -H 'Content-Type: application/x-www-form-urlencoded' \
    -d 'token=用户中心获取&url=https%3A%2F%2Fwww.baidu.com&format=.png&visit=1&ratio=0'
                                       
//记得去掉这个 "\" 斜线
<\?php
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "http://api.toolfk.com/api/captures",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "token=用户中心获取&url=https%3A%2F%2Fwww.baidu.com&format=.png&visit=1&ratio=0",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/x-www-form-urlencoded",
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
   

OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "token=用户中心获取&url=https%3A%2F%2Fwww.baidu.com&format=.png&visit=1&ratio=0");
Request request = new Request.Builder()
  .url("http://api.toolfk.com/api/captures")
  .post(body)
  .addHeader("Content-Type", "application/x-www-form-urlencoded")
  .build();

Response response = client.newCall(request).execute();


                                       
import requests

url = "http://api.toolfk.com/api/captures"

payload = "token=用户中心获取&url=https%3A%2F%2Fwww.baidu.com&format=.png&visit=1&ratio=0"
headers = {'Content-Type': "application/x-www-form-urlencoded"}

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)
var data = "token=用户中心获取&url=https%3A%2F%2Fwww.baidu.com&format=.png&visit=1&ratio=0";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
    if (this.readyState === 4) {
        console.log(this.responseText);
    }
});

xhr.open("POST", "http://api.toolfk.com/api/captures");
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

xhr.send(data);
                                       
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "http://api.toolfk.com/api/captures"

	payload := strings.NewReader("token=用户中心获取&url=https%3A%2F%2Fwww.baidu.com&format=.png&visit=1&ratio=0")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

	res, _ := http.DefaultClient.Do(req)

	async res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
                                       
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "http://api.toolfk.com/api/captures"

        payload := strings.NewReader("{
          "token": "用户中心获取token",
          "type": "a",
          "format": "json"
        }")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

	res, _ := http.DefaultClient.Do(req)

	async res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
                                       
返回状态码 status 描述参照
返回码 描述
status 1:表示成功,0:表示失败
data 成功返回数据
errmsg 失败返回数据
备注:开通API接口服务,可同时享用 www.toolfk.com 网站的会员工具。