返回首页

【工具】网站压缩状态检测

浏览: 1133 最后更新: 2025-03-22 21:47:37

接口说明

一个用于检测指定URL是否启用Gzip压缩及其他压缩方法的在线接口。通过发送HTTP HEAD请求,该接口能够分析并返回目标资源

接口基本信息

API地址

https://api.cenguigui.cn/api/gzip/?url=https://api.cenguigui.cn/

请求方式

GET

返回格式

JSON

接口状态

正常启用

参数说明

以下参数为接口所需调用信息

参数 是否必填 类型 说明 示例
url需要检测的网站

请求示例

HTTP请求

https://api.cenguigui.cn/api/gzip/?url=https://api.cenguigui.cn/

调用示例

代码示例

返回结果

HTTP 200 OK
{
    "code": 200,
    "url": "https://api.cenguigui.cn/",
    "detection_result": {
        "gzip_enabled": "yes",
        "compression_method": "使用 Gzip 压缩方法。这是最常见的压缩方法,能够显著减小传输的数据量。",
        "compression_supported": [
            "gzip"
        ],
        "http_status_code": 200,
        "response_time": 0.132,
        "redirected_url": "https://api.cenguigui.cn/",
        "detection_summary": "目标 URL 启用了压缩。"
    },
    "timestamp": "2025-03-22 21:45:05",
    "tip": "此接口由笒鬼鬼独家开发,购买开源接口源码联系QQ:2963246343"
}

调用示例

// JavaScript调用示例
fetch("https://api.cenguigui.cn/api/gzip/?url=https://api.cenguigui.cn/", {
  method: "GET",
  headers: {
    "Content-Type": "application/json"
  }
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));
# Python调用示例
import requests

url = "https://api.cenguigui.cn/api/gzip/?url=https://api.cenguigui.cn/"

response = requests.get(url)

print(response.json())
// Java调用示例
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;

public class ApiExample {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newBuilder()
                .version(HttpClient.Version.HTTP_2)
                .connectTimeout(Duration.ofSeconds(10))
                .build();
                
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create("https://api.cenguigui.cn/api/gzip/?url=https://api.cenguigui.cn/"))
                .build();
                
        client.sendAsync(request, HttpResponse.BodyHandlers.ofString())
                .thenApply(HttpResponse::body)
                .thenAccept(System.out::println)
                .join();
    }
}
<?php
// PHP调用示例
$url = "https://api.cenguigui.cn/api/gzip/?url=https://api.cenguigui.cn/";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
print_r($result);
?>
// C#调用示例
using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        using var client = new HttpClient();
        var url = "https://api.cenguigui.cn/api/gzip/?url=https://api.cenguigui.cn/";
        
        var response = await client.GetAsync(url);
        
        var result = await response.Content.ReadAsStringAsync();
        Console.WriteLine(result);
    }
}