跳转到主要内容
POST
https://api.aisa.one/apis/v1
/
dataforseo
/
on_page
/
page_screenshot
OnPage API 页面截图
curl --request POST \
  --url https://api.aisa.one/apis/v1/dataforseo/on_page/page_screenshot \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "url": "<string>",
  "accept_language": "<string>",
  "custom_user_agent": "<string>",
  "browser_preset": "<string>",
  "browser_screen_width": 123,
  "browser_screen_height": 123,
  "browser_screen_scale_factor": 123,
  "full_page_screenshot": true,
  "disable_cookie_popup": true,
  "switch_pool": true,
  "ip_pool_for_scan": "<string>"
}
'
import requests

url = "https://api.aisa.one/apis/v1/dataforseo/on_page/page_screenshot"

payload = {
"url": "<string>",
"accept_language": "<string>",
"custom_user_agent": "<string>",
"browser_preset": "<string>",
"browser_screen_width": 123,
"browser_screen_height": 123,
"browser_screen_scale_factor": 123,
"full_page_screenshot": True,
"disable_cookie_popup": True,
"switch_pool": True,
"ip_pool_for_scan": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: '<string>',
accept_language: '<string>',
custom_user_agent: '<string>',
browser_preset: '<string>',
browser_screen_width: 123,
browser_screen_height: 123,
browser_screen_scale_factor: 123,
full_page_screenshot: true,
disable_cookie_popup: true,
switch_pool: true,
ip_pool_for_scan: '<string>'
})
};

fetch('https://api.aisa.one/apis/v1/dataforseo/on_page/page_screenshot', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aisa.one/apis/v1/dataforseo/on_page/page_screenshot",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => '<string>',
'accept_language' => '<string>',
'custom_user_agent' => '<string>',
'browser_preset' => '<string>',
'browser_screen_width' => 123,
'browser_screen_height' => 123,
'browser_screen_scale_factor' => 123,
'full_page_screenshot' => true,
'disable_cookie_popup' => true,
'switch_pool' => true,
'ip_pool_for_scan' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

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

curl_close($curl);

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

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

func main() {

url := "https://api.aisa.one/apis/v1/dataforseo/on_page/page_screenshot"

payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"accept_language\": \"<string>\",\n \"custom_user_agent\": \"<string>\",\n \"browser_preset\": \"<string>\",\n \"browser_screen_width\": 123,\n \"browser_screen_height\": 123,\n \"browser_screen_scale_factor\": 123,\n \"full_page_screenshot\": true,\n \"disable_cookie_popup\": true,\n \"switch_pool\": true,\n \"ip_pool_for_scan\": \"<string>\"\n}")

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

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

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

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.aisa.one/apis/v1/dataforseo/on_page/page_screenshot")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"accept_language\": \"<string>\",\n \"custom_user_agent\": \"<string>\",\n \"browser_preset\": \"<string>\",\n \"browser_screen_width\": 123,\n \"browser_screen_height\": 123,\n \"browser_screen_scale_factor\": 123,\n \"full_page_screenshot\": true,\n \"disable_cookie_popup\": true,\n \"switch_pool\": true,\n \"ip_pool_for_scan\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.aisa.one/apis/v1/dataforseo/on_page/page_screenshot")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"accept_language\": \"<string>\",\n \"custom_user_agent\": \"<string>\",\n \"browser_preset\": \"<string>\",\n \"browser_screen_width\": 123,\n \"browser_screen_height\": 123,\n \"browser_screen_scale_factor\": 123,\n \"full_page_screenshot\": true,\n \"disable_cookie_popup\": true,\n \"switch_pool\": true,\n \"ip_pool_for_scan\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "version": "<string>",
  "status_code": 123,
  "status_message": "<string>",
  "time": "<string>",
  "cost": 123,
  "tasks_count": 123,
  "tasks_error": 123,
  "tasks": [
    "<string>"
  ],
  "tasks.id": "<string>",
  "tasks.status_code": 123,
  "tasks.status_message": "<string>",
  "tasks.time": "<string>",
  "tasks.cost": 123,
  "tasks.result_count": 123,
  "tasks.path": [
    "<string>"
  ],
  "tasks.data": {},
  "tasks.result": [
    "<string>"
  ],
  "tasks.result.crawl_progress": "<string>",
  "tasks.result.error_message": "<string>",
  "tasks.result.items_count": 123,
  "tasks.result.items": [
    "<string>"
  ],
  "tasks.result.items.image": "<string>"
}

授权

Authorization
string
header
必填

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

请求体

application/json
url
string
必填

页面 url,必填字段。要截图的页面绝对 URL。注意:如果您在此处指定的 URL 返回 404 状态代码,或者指定的值不是有效的 URL,则响应数组中会出现 "error_message":"Screenshot is empty"

accept_language
string

访问网站时使用的语言标头;可选字段。支持所有区域设置格式(xx、xx-XX、xxx-XX 等)。注意:如果未指定此参数,某些网站可能会拒绝访问;在这种情况下,响应数组中将出现 "error_message":"Screenshot is empty"

custom_user_agent
string

自定义用户代理。可选字段,用于抓取网站的自定义用户代理。示例:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36。默认值:Mozilla/5.0 (compatible; RSiteAuditor)

browser_preset
string

浏览器屏幕参数预设,可选字段。如果使用此字段,则无需指定 browser_screen_width、browser_screen_height、browser_screen_scale_factor。可选值:desktop, mobile, tablet。desktop 预设将应用以下值:browser_screen_width: 1920 browser_screen_height: 1080 browser_screen_scale_factor: 1。mobile 预设将应用以下值:browser_screen_width: 390 browser_screen_height: 844 browser_screen_scale_factor: 3。tablet 预设将应用以下值:browser_screen_width: 1024 browser_screen_height: 1366 browser_screen_scale_factor: 2。注意:在此端点中,enable_browser_rendering、enable_javascript、load_resources 和 enable_xhr 参数始终处于启用状态。

browser_screen_width
integer

浏览器屏幕宽度 可选字段 你可以设置自定义浏览器屏幕宽度,以针对特定设备执行审计;如果使用此字段,则无需指定 browser_preset,因为它将被忽略;最小值(像素):240 最大值(像素):9999

browser_screen_height
integer

浏览器屏幕高度,可选字段。你可以设置自定义浏览器屏幕高度,以针对特定设备执行审计;如果使用此字段,则无需指定 browser_preset,因为它将被忽略;最小值(像素):240;最大值(像素):9999

browser_screen_scale_factor
number

浏览器屏幕缩放系数 可选字段 你可以设置自定义浏览器屏幕分辨率比例,以针对特定设备执行审计;如果使用此字段,则无需指定 browser_preset,因为它将被忽略;最小值:0.5 最大值:3

full_page_screenshot
boolean

截取完整页面的屏幕截图;可选字段,如果只想截取滚动前显示的页面部分,请设置为 false;默认值:true

禁用 Cookie 弹窗 可选字段;如果要禁用请求用户同意使用 Cookie 的弹窗,请设置为 true;默认值:false

switch_pool
boolean

切换代理池,可选字段;如果为 true,将使用其他代理池获取请求的数据;当同时设置大量任务,偶尔出现限流和/或 site_unreachable 错误时,可以使用此参数

ip_pool_for_scan
string

代理池,可选字段;可选择用于获取所请求数据的代理池位置。如果某一位置无法访问页面内容并偶尔导致 site_unreachable 错误,则可使用此参数。可选值:us, de

响应

成功响应

version
string

API 的当前版本

status_code
integer

通用状态码;您可以在此处查看完整的响应码列表。注意:我们强烈建议设计必要的系统来处理相关异常或错误情况

status_message
string

常规信息消息;可在此处查看常规信息消息的完整列表

time
string

执行时间(秒)

cost
number

任务总成本(美元)

tasks_count
integer

tasks 数组中的任务数量

tasks_error
integer

返回错误的 tasks 数组中的任务数量

tasks
string[]

任务数组

tasks.id
string

任务标识符,系统中采用 UUID 格式的唯一任务标识符

tasks.status_code
integer

DataForSEO 生成的任务状态码;范围为:10000-60000;完整响应代码列表可在此处查看

tasks.status_message
string

任务的信息性消息,你可以在此处查看通用信息性消息的完整列表

tasks.time
string

执行时间(秒)

tasks.cost
number

任务成本(美元)

tasks.result_count
integer

结果数组中的元素数量

tasks.path
string[]

URL 路径

tasks.data
object

包含您在 POST 请求中指定的相同参数

tasks.result
string[]

结果数组

tasks.result.crawl_progress
string

抓取会话的状态,可能的值:in_progress、finished

tasks.result.error_message
string

错误消息;如果您指定的 url 返回 404 状态码或不是有效的 URL,将获得 "error_message":"Screenshot is empty";如果未遇到错误,该值将为 null

tasks.result.items_count
integer

results 数组中的项目数量

tasks.result.items
string[]

items 数组

tasks.result.items.image
string

所请求页面的截图;DataForSEO 存储空间中页面截图的 URL