接入教程
1. 注册获取API密钥。2. 使用提供的URL结构发送请求。3. 根据需要调整参数如视口、延迟等。
Python示例
python
import requests
url = 'http://api.screenshotlayer.com/api/capture'
params = {
'access_key': 'YOUR_ACCESS_KEY',
'url': 'http://example.com',
'viewport': '1440x900'
}
response = requests.get(url, params=params)
print(response.url)
PHP示例
php
<?php
$url = 'http://api.screenshotlayer.com/api/capture';
$params = array(
'access_key' => 'YOUR_ACCESS_KEY',
'url' => 'http://example.com',
'viewport' => '1440x900'
);
$request_url = $url . '?' . http_build_query($params);
echo file_get_contents($request_url);
?>
JavaScript示例
javascript
const fetch = require('node-fetch');
const url = 'http://api.screenshotlayer.com/api/capture';
const params = new URLSearchParams({
'access_key': 'YOUR_ACCESS_KEY',
'url': 'http://example.com',
'viewport': '1440x900'
});
fetch(`${url}?${params}`)
.then(response => console.log(response.url))
.catch(error => console.error(error));
常见问题
截图层API是否免费?
是的,提供每月100次免费截图,超出部分需订阅付费计划。
支持哪些图片格式?
支持PNG、JPEG、GIF和WebP格式。
如何自定义截图尺寸?
通过设置`viewport`和`width`参数来自定义截图尺寸。
Aitishiku.com