首页 / 帮助文档 / 网页解锁器使用教程

网页解锁器使用教程

Web Unlocker User Guide

一个接口拿回渲染完成的页面:开通次数包、Bearer 令牌认证、9 个请求参数、curl/Python/Node 示例与计费排查。
One API call returns a fully rendered page: plans, Bearer token, all 9 request parameters, curl / Python / Node examples and billing notes.

一、网页解锁器是什么

网页解锁器(Web Unlocker)把「取回一个公开网页」这件事封装成一次 API 请求。平台在服务端自动完成出口调度、JavaScript 渲染、重定向跟随和重试,你直接拿到渲染后的 HTML 或整页截图,不需要自己维护代理池、浏览器集群或验证码处理逻辑。

二、开通与获取访问令牌

  1. 登录 IPLight 控制台,进入「网页解锁器」。
  2. 在套餐区购买次数包;购买成功后账户即可调用接口。
  3. 在页面的「接入示例」区域复制访问令牌(Bearer Token)。请求头必须使用 Authorization: Bearer <您的访问令牌>。

令牌安全:访问令牌等同于账户调用权限,请勿写进前端代码、公开仓库或截图;泄露后请在控制台重新生成。

三、接口说明

POST /api/dyn/unblocker/fetch
Authorization: Bearer <您的访问令牌>
Content-Type: application/json

{
  "target_url": "https://www.example.com",
  "response_format": "html",
  "js_render": "True",
  "country": "us",
  "follow_redirect": "True"
}

请求体为 JSON。返回值在成功时包含渲染后的页面内容(html)或 png 截图数据;失败时返回错误信息,可在控制台「近期请求」中查看每次调用的状态与耗时。

请求参数

参数必填说明
target_url是目标网址,公网可访问的 http/https 地址。
response_format否输出格式:html(默认)或 png(整页截图)。
js_render否JS 渲染:True/False,开启后可获取动态加载内容(推荐)。
country否出口国家代码(如 us、hk),不填为随机出口。
block_resources否屏蔽资源:image(图片)/ script(脚本),加快抓取速度。
clean_content否清理内容:js,css(从结果中移除脚本与样式)。
wait否页面加载等待时间(毫秒,最大 100000)。
wait_for否等待 CSS 选择器出现(如 .content),最长 30 秒。
follow_redirect否跟随重定向:True(默认)/ False。

四、代码示例

curl

curl -X POST "https://api.iplight.net/api/dyn/unblocker/fetch" \
  -H "Authorization: Bearer $IPL_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "target_url": "https://www.example.com",
    "response_format": "html",
    "js_render": "True",
    "country": "us"
  }'

Python

import os, requests

resp = requests.post(
    "https://api.iplight.net/api/dyn/unblocker/fetch",
    headers={"Authorization": "Bearer " + os.environ["IPL_TOKEN"]},
    json={
        "target_url": "https://www.example.com",
        "response_format": "html",
        "js_render": "True",
        "country": "us",
    },
    timeout=120,
)
resp.raise_for_status()
print(resp.text[:500])

Node.js

const res = await fetch("https://api.iplight.net/api/dyn/unblocker/fetch", {
  method: "POST",
  headers: {
    "Authorization": "Bearer " + process.env.IPL_TOKEN,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    target_url: "https://www.example.com",
    response_format: "html",
    js_render: "True",
    country: "us",
  }),
});
console.log((await res.text()).slice(0, 500));

五、计费与结果查看

六、常见问题

Q:返回 401 / 令牌无效? 检查 Authorization 是否带 Bearer 前缀、令牌是否完整复制、是否已重新生成过令牌。

Q:拿到的 HTML 缺少列表或价格? 开启 js_render: "True";内容异步加载时补 wait(毫秒)或 wait_for(CSS 选择器)。

Q:页面内容与预期地区不一致? 指定 country;不填时为随机出口,本地化页面可能随出口变化。

Q:抓取速度慢? 用 block_resources: "image" 屏蔽图片,或关闭 JS 渲染(仅静态页面)。

Q:只要截图怎么办? 把 response_format 设为 png 即可获得整页截图。

七、合规提示

请仅对公开可访问、且你有权访问的页面使用本服务,遵守目标站点的服务条款与当地法律。产品不支持任何形式的翻墙服务,仅支持在中国大陆境外网络环境下合法合规使用。

1. What is Web Unlocker

Web Unlocker turns "fetch a public page" into a single API call. The platform handles exit routing, JavaScript rendering, redirects and retries on the server side, and returns rendered HTML or a full-page screenshot. You do not need to maintain a proxy pool, a browser cluster or CAPTCHA handling.

2. Get started and obtain a token

  1. Sign in to the IPLight console and open Web Unlocker.
  2. Buy a request pack in the plan section. The account can call the API immediately after purchase.
  3. Copy the access token from the API example panel. Every request must send Authorization: Bearer <YOUR_TOKEN>.

Keep the token private. It grants API access to your account. Never commit it to a public repository or paste it into client-side code; regenerate it in the console if leaked.

3. API reference

POST /api/dyn/unblocker/fetch
Authorization: Bearer <YOUR_TOKEN>
Content-Type: application/json

{
  "target_url": "https://www.example.com",
  "response_format": "html",
  "js_render": "True",
  "country": "us",
  "follow_redirect": "True"
}

The request body is JSON. A successful call returns the rendered page (html) or png screenshot data. Failed calls return an error; the console Recent requests panel shows status and latency for every call.

Request parameters

ParameterRequiredDescription
target_urlYesTarget URL, a publicly reachable http/https address.
response_formatNoOutput format: html (default) or png (full-page screenshot).
js_renderNoJS rendering: True/False. Enable for dynamically loaded content (recommended).
countryNoExit country code such as us or hk; random exit when omitted.
block_resourcesNoBlock resources: image or script for faster fetching.
clean_contentNoClean content: js,css strips scripts and styles from the result.
waitNoPage load wait in milliseconds, up to 100000.
wait_forNoWait for a CSS selector, e.g. .content, up to 30 seconds.
follow_redirectNoFollow redirects: True (default) / False.

4. Code examples

curl

curl -X POST "https://api.iplight.net/api/dyn/unblocker/fetch" \
  -H "Authorization: Bearer $IPL_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "target_url": "https://www.example.com",
    "response_format": "html",
    "js_render": "True",
    "country": "us"
  }'

Python

import os, requests

resp = requests.post(
    "https://api.iplight.net/api/dyn/unblocker/fetch",
    headers={"Authorization": "Bearer " + os.environ["IPL_TOKEN"]},
    json={
        "target_url": "https://www.example.com",
        "response_format": "html",
        "js_render": "True",
        "country": "us",
    },
    timeout=120,
)
resp.raise_for_status()
print(resp.text[:500])

Node.js

const res = await fetch("https://api.iplight.net/api/dyn/unblocker/fetch", {
  method: "POST",
  headers: {
    "Authorization": "Bearer " + process.env.IPL_TOKEN,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    target_url: "https://www.example.com",
    response_format: "html",
    js_render: "True",
    country: "us",
  }),
});
console.log((await res.text()).slice(0, 500));

5. Billing and request history

6. Troubleshooting

Q: 401 or invalid token? Check that Authorization includes the Bearer prefix, that the token was copied in full, and that it was not regenerated.

Q: Lists or prices are missing from the HTML? Enable js_render: "True"; for async content add wait (ms) or wait_for (CSS selector).

Q: Content does not match the expected region? Set country; without it the exit is random and localized pages may vary.

Q: Fetching is slow? Use block_resources: "image", or disable JS rendering for static pages.

Q: I only need a screenshot? Set response_format to png.

7. Compliance

Use this service only for publicly accessible pages you are authorized to access, and follow the target site's terms and local law. The product does not support circumvention and is intended for lawful use outside mainland China.

更多文档 IPLight 帮助文档中心 · 开发者文档 · support@iplight.net · 返回官网