API phổ quátTính năngJS Render

JS Render

Universal Scraping API là một dịch vụ truy xuất nội dung web mạnh mẽ hỗ trợ các kịch bản render và tương tác trang web phức tạp.

Tham khảo tài liệu API của chúng tôi để biết thêm chi tiết.

Cấu trúc Yêu cầu Cơ bản

{
  "actor": "unlocker.webunlocker",
  "input": {
    "url": "https://example.com",
    "js_render": false,
    "headless": false
  },
  "proxy": {
    "country": "US"
  }
}

Các Tính năng Chính

Rendering JavaScript

Rendering JavaScript cho phép xử lý nội dung được tải động và SPA (Ứng dụng trang đơn). Cho phép môi trường trình duyệt hoàn chỉnh, hỗ trợ các tương tác và yêu cầu render trang phức tạp hơn.

js_render=true, chúng tôi sẽ sử dụng trình duyệt để yêu cầu.

{
  "actor": "unlocker.webunlocker",
  "input": {
    "url": "https://www.google.com/",
    "js_render": true
  },
  "proxy": {
    "country": "US"
  }
}

Hướng dẫn JavaScript

Cung cấp một bộ hướng dẫn JavaScript mở rộng cho phép bạn tương tác động với các trang web.

Những hướng dẫn này cho phép bạn nhấp vào các phần tử, điền vào biểu mẫu, gửi biểu mẫu hoặc chờ các phần tử cụ thể xuất hiện, cung cấp tính linh hoạt cho các tác vụ như nhấp vào nút “đọc thêm” hoặc gửi biểu mẫu.

{
  "actor": "unlocker.webunlocker",
  "input": {
    "url": "https://example.com",
    "js_render": true,
    "js_instructions": [
      {
        "wait_for": [
          ".dynamic-content",
          30000
        ]
        // Chờ phần tử
      },
      {
        "click": [
          "#load-more",
          1000
        ]
        // Nhấp vào phần tử
      },
      {
        "fill": [
          "#search-input",
          "search term"
        ]
        // Điền vào form
      },
      {
        "keyboard": [
          "press",
          "Enter"
        ]
        // Mô phỏng nhấn phím
      },
      {
        "evaluate": "window.scrollTo(0, document.body.scrollHeight)"
        // Thực thi JS tùy chỉnh
      }
    ]
  }
}

Dưới đây là một số hành động phổ biến bạn có thể thực hiện với Hướng dẫn JavaScript:

Tài liệu tham khảo Hướng dẫn JavaScript

Hướng dẫnCú phápMô tảVí dụ
wait_for[selector, timeout]Chờ phần tử xuất hiện{"wait_for": [".content", 30000]}
click[selector, delay]Nhấp vào phần tử{"click": [".button", 1000]}
fill[selector, value]Điền vào form{"fill": ["#input", "text"]}
waitmillisecondsThời gian chờ cố định{"wait": 2000}
evaluatejavascript_codeThực thi mã JS{"evaluate": "console.log('test')"}
keyboard[action, value, delay?]Thao tác bàn phímXem bảng thao tác bàn phím bên dưới

Thao tác bàn phím

Thao tácCú phápMô tảVí dụ
Nhấn phím["press", keyInput]Nhấn một keyInput cụ thể{"keyboard": ["press", "Enter"]}
Nhập văn bản["type", text, delay?]Nhập văn bản với độ trễ tùy chọn{"keyboard": ["type", "Hello", 20]}
Nhấn giữ phím["down", key]Giữ một phím{"keyboard": ["down", "Shift"]}
Nhả phím["up", key]Nhả một phím{"keyboard": ["up", "Shift"]}

Các kiểu Special KeyInput được hỗ trợ: https://pptr.dev/api/puppeteer.keyinput

Loại phản hồi

Bạn có thể lọc các giá trị bằng tham số output, và kết quả sẽ được trả về ở định dạng chuỗi JSON. Bạn cũng có thể chỉ định các loại trả về khác như html, markdown bằng tham số response_type.

Bộ lọc đầu ra

Bạn có thể lọc dữ liệu được định dạng JSON bằng tham số outputs. Sau khi được chỉ định, phản hồi sẽ được cố định ở định dạng chuỗi JSON. Tham số này cho phép bạn xác định chính xác loại dữ liệu nào cần trích xuất từ ​​HTML đã thu thập, cho phép truy xuất hiệu quả chỉ thông tin cần thiết. Bằng cách này, bạn có thể giảm thời gian xử lý và tập trung vào dữ liệu liên quan nhất cho trường hợp sử dụng của mình.

Tham số này chấp nhận danh sách các loại bộ lọc được phân tách bằng dấu phẩy và trả về kết quả ở định dạng chuỗi JSON có cấu trúc. Các loại bộ lọc được phép bao gồm:

phone_numbers, headings, images, audios, videos, links, menus, hashtags, emails, metadata, tables, favicon.

Để biết cách sử dụng chi tiết, hãy kiểm tra mã bên dưới.

const axios =require('axios');
const fs =require('fs');
 
(async () => {
    // Cấu hình
    const url = "https://api.scrapeless.com/api/v1/unlocker/request";
    const token = "API Key";
 
    const headers = {"x-api-token": token, "Content-Type": "application/json"};
 
    const payload = {
        actor: "unlocker.webunlocker",
        input: {
            url: "https://www.example.com",
            js_render: true, // phải là true
            outputs: "phone_numbers, headings, images, audios, videos, links, menus, hashtags, emails, metadata, tables, favicon" // bộ lọc đầu ra
        },
        proxy: {
            country: "ANY"
        }
    };
 
    try {
        const response = await axios.post(url, payload, {headers, timeout: 60000});
 
        if (response.status !== 200) {
            throw newError(`Lỗi HTTP: ${response.status}`);
        }
 
        const data = response.data;
        if (data.code !== 200) {
            throw newError(`Lỗi API: ${data}`);
        }
 
        const content = data.data || '';
 
        // Lưu và trả về kết quả
        fs.writeFileSync('response.json', content, 'utf8');
console.log('✅ Thành công! Nội dung đã được lưu dưới dạng response.json');
 
        returnJSON.parse(content);
 
    } catch (error) {
console.error('❌ Lỗi:', error.message);
        throw error;
    }
})()
 

Dưới đây là một số ví dụ:

Email

Sử dụng bộ chọn CSS và biểu thức chính quy để trích xuất địa chỉ email ở định dạng chuẩn, chẳng hạn như example@example.com.

{
    "code": 200,
    "data": "{\"emails\":[\"market@scrapeless.com\"]}"
}
 
Số điện thoại

Sử dụng bộ chọn CSS và biểu thức chính quy để trích xuất số điện thoại, tập trung vào các liên kết chứa giao thức tel:.

ví dụ: outputs=phone_numbers

{
    "code": 200,
    "data": "{ \"phone_numbers\": [ \"+1-111-111-111\" ] }"
}
 
Tiêu đề

Trích xuất văn bản tiêu đề từ H1 đến H6 trong HTML.

ví dụ: outputs=headings

{
    "code": 200,
    "data": "{\"headings\":[\"Example Domain\"]}"
}
 
Hình ảnh

Trích xuất nguồn hình ảnh từ thẻ img. Chỉ trả về thuộc tính src.

ví dụ: outputs=images

{
    "code": 200,
    "data": "{\"images\":[\"https://www.scrapeless.com/_next/image?url=%2Fassets%2Fimages%2Ftoolkit%2Flight%2Fimg-2.png&w=750&q=100\"]}"
}
 
Âm thanh

Trích xuất nguồn âm thanh từ các phần tử source bên trong thẻ audio. Chỉ trả về thuộc tính src.

ví dụ: outputs=audios

{
    "code": 200,
    "data": "{\"audios\":[\"https://example.com/audio.mp3\"]}"
}
 
Video

Trích xuất nguồn video từ các phần tử source bên trong thẻ video. Chỉ trả về thuộc tính src.

ví dụ: outputs=videos

{
    "code": 200,
    "data": "{\"videos\":[\"https://example.com/video.mp4\"]}"
}
 
Liên kết

Trích xuất URL từ thẻ a. Chỉ trả về thuộc tính href.

ví dụ: outputs=links

{
    "code": 200,
    "data": "{\"links\":[\"https://app.scrapeless.com/landing/guide\",\"https://www.scrapeless.com/en\",\"https://www.scrapeless.com/en/pricing\",\"https://docs.scrapeless.com/\",\"https://backend.scrapeless.com/app/api\",\"https://www.producthunt.com/posts/scrapeless-deep-serpapi\",\"https://www.g2.com/products/scrapeless/reviews\",\"https://www.trustpilot.com/review/scrapeless.com\",\"https://slashdot.org/software/p/Scrapeless/\",\"https://tekpon.com/software/scrapeless/reviews/\",\"https://www.scrapeless.com/en/product/deep-serp-api\",\"https://www.scrapeless.com/en/product/scraping-browser\",\"https://www.scrapeless.com/en/product/scraping-api\",\"https://www.scrapeless.com/en/product/universal-scraping-api\",\"https://www.scrapeless.com/en/solutions/e-commerce\",\"https://www.scrapeless.com/en/solutions/seo\",\"https://www.scrapeless.com/en/solutions/real-estate\",\"https://www.scrapeless.com/en/solutions/travel-hotel-airline\",\"https://www.scrapeless.com/en/solutions/social-media\",\"https://www.scrapeless.com/en/solutions/market-research\",\"https://www.scrapeless.com/en/blog\",\"https://www.scrapeless.com/en/blog/deep-serp-api-online\",\"https://www.scrapeless.com/en/blog/scrapeless-web-scraping-toolkit\",\"https://www.scrapeless.com/en/blog/google-shopping-scrape\",\"https://backend.scrapeless.com/app/api/v1/public/links/github\",\"https://backend.scrapeless.com/app/api/v1/public/links/youtube\",\"mailto:market@scrapeless.com\",\"https://www.scrapeless.com/en/ai-agent\",\"https://browserless.scrapeless.com/\",\"https://www.scrapeless.com/en/solutions/temu\",\"https://www.scrapeless.com/en/solutions/walmart\",\"https://www.scrapeless.com/en/solutions/shopee\",\"https://www.scrapeless.com/en/solutions/lazada\",\"https://www.scrapeless.com/en/solutions/amazon\",\"https://www.scrapeless.com/en/solutions/google-trends\",\"https://www.scrapeless.com/en/solutions/google-search\",\"https://www.scrapeless.com/en/solutions/airbnb\",\"https://www.scrapeless.com/en/solutions/scoot\",\"https://www.scrapeless.com/en/solutions/latam\",\"https://www.scrapeless.com/en/solutions/localiza\",\"https://www.scrapeless.com/en/solutions/tiktok\",\"https://www.scrapeless.com/en/solutions/instagram\",\"https://www.scrapeless.com/en/integration\",\"https://www.scrapeless.com/en/faq\",\"https://www.scrapeless.com/en/glossary\",\"https://www.scrapeless.com/en/legal/privacy-policy\",\"https://www.scrapeless.com/en/legal/terms\",\"https://www.scrapeless.com/en/legal/terms#refund-policy\",\"https://www.scrapeless.com/en/legal/check-your-data\",\"https://backend.scrapeless.com/app/api/v1/public/links/discord\"]}"
}
 

Trích xuất các mục menu từ các phần tử li bên trong thẻ menu.

ví dụ: outputs=menus

{
    "code": 200,
    "data": "{\"links\":[ \"Coffee\", \"Tea\", \"Milk\" ]}"
}
 
Hashtags

Trích xuất các định dạng hashtag bằng biểu thức chính quy để khớp với các mẫu hashtag điển hình, chẳng hạn như #example.

ví dụ: outputs = hashtags

{
    "code": 200,
    "data": "{\"hashtags\":[\"#docsearch\",\"#search\"]}"
}
 
Metadata

Trích xuất thông tin siêu dữ liệu từ thẻ meta trong phần head, trả về các thuộc tính namecontent ở định dạng name: content.

ví dụ: outputs=metadata

{
    "code": 200,
    "data": "{\"metadata\":[\"viewport: width=device-width, initial-scale=1\",\"description: Scrapeless is the best full-stack web scraping toolkit offering Scraping API, Scraping Browser\"]}"
}
 
Bảng

Trích xuất dữ liệu từ các phần tử bảng và trả về dữ liệu bảng ở định dạng JSON, bao gồm kích thước, tiêu đề và nội dung.

ví dụ: outputs=tables

{
    "code": 200,
    "data": "{\"tables\":[{\"dimensions\":{\"rows\":7,\"columns\":3,\"heading\":true},\"heading\":[\"Company\",\"Contact\",\"Country\"],\"content\":[{\"Company\":\"Alfreds Futterkiste\",\"Contact\":\"Maria Anders\",\"Country\":\"Germany\"},{\"Company\":\"Centro comercial Moctezuma\",\"Contact\":\"Francisco Chang\",\"Country\":\"Mexico\"},{\"Company\":\"Ernst Handel\",\"Contact\":\"Roland Mendel\",\"Country\":\"Austria\"},{\"Company\":\"Island Trading\",\"Contact\":\"Helen Bennett\",\"Country\":\"UK\"},{\"Company\":\"Laughing Bacchus Winecellars\",\"Contact\":\"Yoshi Tannamuri\",\"Country\":\"Canada\"},{\"Company\":\"Magazzini Alimentari Riuniti\",\"Contact\":\"Giovanni Rovelli\",\"Country\":\"Italy\"}]},{\"dimensions\":{\"rows\":11,\"columns\":2,\"heading\":true},\"heading\":[\"Tag\",\"Description\"],\"content\":[{\"Tag\":\"<table>\",\"Description\":\"Defines a table\"},{\"Tag\":\"<th>\",\"Description\":\"Defines a header cell in a table\"},{\"Tag\":\"<tr>\",\"Description\":\"Defines a row in a table\"},{\"Tag\":\"<td>\",\"Description\":\"Defines a cell in a table\"},{\"Tag\":\"<caption>\",\"Description\":\"Defines a table caption\"},{\"Tag\":\"<colgroup>\",\"Description\":\"Specifies a group of one or more columns in a table for formatting\"},{\"Tag\":\"<col>\",\"Description\":\"Specifies column properties for each column within a <colgroup> element\"},{\"Tag\":\"<thead>\",\"Description\":\"Groups the header content in a table\"},{\"Tag\":\"<tbody>\",\"Description\":\"Groups the body content in a table\"},{\"Tag\":\"<tfoot>\",\"Description\":\"Groups the footer content in a table\"}]}]}"
}
 
Favicon

Trích xuất URL favicon từ phần tử link trong phần head của HTML.

ví dụ: outputs = favicon

{
    "code": 200,
    "data": "{\"favicon\":\"https://www.scrapeless.com/favicon.ico\"}"
}
 

Các định dạng khác

Ngoài việc lọc dữ liệu JSON thông qua tham số outputs, bạn cũng có thể chỉ định nhiều loại giá trị trả về hơn bằng cách chỉ định tham số response_type. Các giá trị tùy chọn là: html | plaintext | markdown | png/jpeg, với giá trị mặc định là html. Chi tiết như sau:

HTML

Được sử dụng để trích xuất nội dung HTML của một trang, hoạt động tốt nhất đối với các trang tĩnh thuần túy và trả về nội dung ở định dạng chuỗi HTML đã được thoát.

Thêm response_type=html vào yêu cầu:

const axios = require('axios');
const fs = require('fs');
 
(async () => {
    const payload = {
        actor: "unlocker.webunlocker",
        input: {
            url: "https://www.example.com",
            js_render: true,
            response_type: "html"
        },
        proxy: {
            country: "ANY"
        }
    };
 
    const response = await axios.post("https://api.scrapeless.com/api/v1/unlocker/request", payload, {
        headers: {
            "x-api-token": "API Key",
            "Content-Type": "application/json"
        },
        timeout: 60000
    });
 
    if (response.data?.code === 200) {
        fs.writeFileSync('response.html', response.data.data, 'utf8');
    }
})();

Trả về nội dung văn bản ở định dạng HTML.

{
    "code": 200,
    "data": "<!DOCTYPE html><html><head>\n    <title>Example Domain</title>\n\n    <meta charset=\"utf-8\">\n    <meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n    <style type=\"text/css\">\n    body {\n        background-color: #f0f0f2;\n        margin: 0;\n        padding: 0;\n        font-family: -apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", \"Open Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n        \n    }\n    div {\n        width: 600px;\n        margin: 5em auto;\n        padding: 2em;\n        background-color: #fdfdff;\n        border-radius: 0.5em;\n        box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);\n    }\n    a:link, a:visited {\n        color: #38488f;\n        text-decoration: none;\n    }\n    @media (max-width: 700px) {\n        div {\n            margin: 0 auto;\n            width: auto;\n        }\n    }\n    </style>    \n</head>\n\n<body>\n<div>\n    <h1>Example Domain</h1>\n    <p>This domain is for use in illustrative examples in documents. You may use this\n    domain in literature without prior coordination or asking for permission.</p>\n    <p><a href=\"https://www.iana.org/domains/example\">More information...</a></p>\n</div>\n\n\n</body></html>"
}

Nội dung ví dụ của tệp HTML sau khi lưu:

<!DOCTYPE html><html><head>
    <title>Example Domain</title>
 
    <meta charset="utf-8">
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style type="text/css">
    body {
        background-color: #f0f0f2;
        margin: 0;
        padding: 0;
        font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
 
    }
    div {
        width: 600px;
        margin: 5em auto;
        padding: 2em;
        background-color: #fdfdff;
        border-radius: 0.5em;
        box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);
    }
    a:link, a:visited {
        color: #38488f;
        text-decoration: none;
    }
    @media (max-width: 700px) {
        div {
            margin: 0 auto;
            width: auto;
        }
    }
    </style>
</head>
 
<body>
<div>
    <h1>Example Domain</h1>
    <p>This domain is for use in illustrative examples in documents. You may use this
    domain in literature without prior coordination or asking for permission.</p>
    <p><a href="https://www.iana.org/domains/example">More information...</a></p>
</div>
 
</body></html>
Văn bản thuần túy

Tính năng văn bản thuần túy là một tùy chọn đầu ra trả về nội dung đã thu thập ở định dạng văn bản thuần túy thay vì HTML hoặc Markdown. Tính năng này rất thiết thực khi cần một phiên bản nội dung sạch, không được định dạng (không có bất kỳ thẻ HTML hoặc định dạng Markdown nào). Nó đơn giản hóa quá trình trích xuất nội dung, giúp việc xử lý hoặc phân tích văn bản thuận tiện hơn.

Thêm response_type=plaintext vào yêu cầu:

const axios = require('axios');
const fs = require('fs');
 
(async () => {
    const payload = {
        actor: "unlocker.webunlocker",
        input: {
            url: "https://www.example.com",
            js_render: true,
            response_type: "plaintext"
        },
        proxy: {
            country: "ANY"
        }
    };
 
    const response = await axios.post("https://api.scrapeless.com/api/v1/unlocker/request", payload, {
        headers: {
            "x-api-token": "API Key",
            "Content-Type": "application/json"
        },
        timeout: 60000
    });
 
    if (response.data?.code === 200) {
        fs.writeFileSync('response.txt', response.data.data, 'utf8');
    }
})();

Trả về nội dung văn bản thuần túy của trang dưới dạng chuỗi. Xem ví dụ bên dưới.

{
    "code": 200,
    "data": "Example Domain\n\nThis domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.\n\nMore information..."
}

Nội dung ví dụ của tệp txt sau khi lưu:

Example Domain

This domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.

More information...
Markdown

Đối với việc trích xuất nội dung trang ở định dạng Markdown, các trang Markdown tĩnh thuần túy hoạt động tốt nhất. Bằng cách thêm response_type=markdown vào các tham số yêu cầu, Universal Scraping API sẽ trả về nội dung ở định dạng Markdown, giúp dễ đọc và dễ xử lý hơn.

Thêm response_type=markdown vào yêu cầu:

const axios = require('axios');
const fs = require('fs');
 
(async () => {
    const payload = {
        actor: "unlocker.webunlocker",
        input: {
            url: "https://www.example.com",
            js_render: true,
            response_type: "markdown"
        },
        proxy: {
            country: "ANY"
        }
    };
 
    const response = await axios.post("https://api.scrapeless.com/api/v1/unlocker/request", payload, {
        headers: {
            "x-api-token": "API Key",
            "Content-Type": "application/json"
        },
        timeout: 60000
    });
 
    if (response.data?.code === 200) {
        fs.writeFileSync('response.md', response.data.data, 'utf8');
    }
})();
 

Trả về nội dung văn bản ở định dạng Markdown.

{
    "code": 200,
    "data": "# Example Domain\n\nThis domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.\n\n[More information...](https://www.iana.org/domains/example)"
}

Nội dung ví dụ sau khi lưu tệp Markdown:

# Example Domain
 
This domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.
 
[More information...](https://www.iana.org/domains/example)
 
PNG/JPEG

Bằng cách thêm response_type=png vào yêu cầu, bạn có thể chụp ảnh màn hình của trang đích và trả về hình ảnh ở định dạng PNG hoặc JPEG. Khi kết quả phản hồi được đặt thành PNG hoặc JPEG, bạn có thể sử dụng tham số response_image_full_page=true để chỉ định xem kết quả trả về là ảnh chụp màn hình toàn trang hay không. Giá trị mặc định của tham số response_image_full_page là false.

Thêm response_type=png vào yêu cầu:

const axios = require('axios');
const fs = require('fs');
 
(async () => {
    const payload = {
        actor: "unlocker.webunlocker",
        input: {
            url: "https://www.example.com",
            js_render: true,
            response_type: "png", // png hoặc jpeg
            response_image_full_page: true
        },
        proxy: {
            country: "ANY"
        }
    };
 
    const response = await axios.post("https://api.scrapeless.com/api/v1/unlocker/request", payload, {
        headers: {
            "x-api-token": "API Key",
            "Content-Type": "application/json"
        },
        timeout: 60000
    });
 
    if (response.data?.code === 200) {
        fs.writeFileSync('response.png',Buffer.from(response.data.data, 'base64'));
    }
})();

Trả về một chuỗi được mã hóa base64 ở định dạng PNG hoặc JPEG.

{
    "code": 200,
    "data": "JVBERi0xLjQKJdPr6eEKM..."
}

Tệp ví dụ sau khi lưu ở định dạng png/jpeg:

Điều khiển Tài nguyên

Hệ thống điều khiển tải tài nguyên để tối ưu hiệu suất và sử dụng băng thông.

{
  "actor": "unlocker.webunlocker",
  "input": {
    "url": "https://example.com",
    "js_render": true,
    "block": {
      "resources": [
        "Image",
        "Font",
        "Stylesheet",
        "Script"
      ],
      "urls": [
        // Tùy chọn, chặn dựa trên mẫu URL
        "*.analytics.com/*",
        "*/ads/*"
      ]
    }
  }
}

Tham chiếu đầy đủ về các loại tài nguyên:

Loại Tài nguyênMô tảTác động
DocumentTài liệu chính và iframeNội dung trang cốt lõi
StylesheetTệp CSSKiểu trang và bố cục
ImageHình ảnh và biểu tượngNội dung trực quan
MediaTài nguyên âm thanh và videoNội dung đa phương tiện
FontPhông chữ webHiển thị văn bản
ScriptTệp JavaScriptChức năng trang
TextTrackPhụ đề và chú thích videoTrợ năng đa phương tiện
XHRCuộc gọi XMLHttpRequestYêu cầu không đồng bộ cũ
FetchYêu cầu Fetch APIYêu cầu không đồng bộ hiện đại
PrefetchTài nguyên được tải trướcTối ưu hóa hiệu năng
EventSourceSự kiện do máy chủ gửiCập nhật thời gian thực
WebSocketKết nối WebSocketGiao tiếp hai chiều
ManifestBản kê khai ứng dụng webCấu hình PWA
SignedExchangeTrao đổi HTTP đã kýTính xác thực nội dung
PingYêu cầu PingPhân tích và theo dõi
CSPViolationReportBáo cáo vi phạm CSPGiám sát bảo mật
PreflightYêu cầu CORS preflightBảo mật đa nguồn gốc
OtherTài nguyên không được phân loạiKhác nhau

Ví dụ sử dụng:

{
  "actor": "unlocker.webunlocker",
  "input": {
    "url": "https://example.com",
    "js_render": true,
    "block": {
      "resources": [
        "Image",
        "Font",
        "Stylesheet",
        "Script",
        "Media",
        "Ping",
        "Prefetch"
      ]
    }
  }
}

Thực tiễn tốt nhất để chặn tài nguyên:

  1. Tối ưu hóa hiệu suất

    • Chỉ bật js_render khi cần thiết
    • Sử dụng chặn tài nguyên một cách khôn ngoan, Chặn các tài nguyên không cần thiết để tải nhanh hơn
    • Cân nhắc chặn PrefetchPing để giảm sử dụng mạng
    • Giữ Document và các tài nguyên Script quan trọng không bị chặn
  2. Quản lý băng thông

    • Chặn ImageMedia đối với các trang sử dụng nhiều băng thông
    • Cân nhắc chặn Font để sử dụng phông chữ hệ thống thay thế
  3. Nâng cao độ ổn định

    • Thực hiện cơ chế thử lại yêu cầu
    • Thêm logic xử lý lỗi
    • Sử dụng wait_for thay vì wait cố định
  4. Hiệu quả tài nguyên

    • Tải tài nguyên theo yêu cầu
    • Đóng các kết nối không cần thiết ngay lập tức

Lưu ý: Chuỗi loại tài nguyên phân biệt chữ hoa chữ thường. Sử dụng khớp chính xác như trong bảng tham chiếu.