简单的服务器侧集成
Begin with api_key and a URL-encoded url. Add method, location, rendering, response, or asynchronous options only when the workload requires them.
一个管理请求
Begin with api_key and a URL-encoded url. Add method, location, rendering, response, or asynchronous options only when the workload requires them.
WebScrapingAPI operates proxy routing, rotation, access-handling strategies, and internal target retries behind the API request.
Review managed featuresReturn the page body, a JSON envelope, a JSON DOM, customer-defined selected fields, or an explicit documented error state.
Review response formats自动访问功能
配置您的工作流需要的背景. WebScrapingAPI 运行支持访问基础设施,同时让未成功的状态可见于客户端.
01
服务选择并运行每个支持请求背景背后的代理路线.
02
实现自动化访问策略和内部 target重复尝试,减少了您的应用程序必须运行的基础设施.
03
验证,访问,费率和服务错误仍然明确,
04
设置 render_js=1 在返回页面响应之前,需要客户端执行target.
05
要求记录一个国家和支持的城市,州或ASN文本,当位置影响响应时.
06
使用支持的方法,可选的体,时间限,异步检索,JSON模式或提取规则.
保存页面体,将其包装成请求元数据,在API边界执行选项,或稍后检索排队结果.
使用现有解析器的默认页面体.
检查机构, target标题,初始状态,类型,成本和元数据.
执行客户所有的CSS或XPath选项,用于文本,HTML,属性,表格或嵌入式记录.
提交工作异步,并使用其标识符检索完成的响应.
提取界限:您的团队拥有该方案,选择器,业务领域验证和源更改维护.当这些义务转移到WebScrapingAPI时,选择数据 API或托管数据
如何运行
提供API密钥,target URL,以及工作负载所需的文档文本或输出选项.
该服务验证请求,运行代理路由,应用访问处理和内部重试,并在请求时将JavaScript转换.
使用返回页面体,JSON封面,选定的字段或已存在的应用程序中记录错误.
开发人员集成
保持API关键服务器侧,编码target,从基本请求开始,只需要工作负载时添加染,地理或提取.
WSA_API_KEY server-sidecurl --get --fail-with-body --max-time 120 \
"https://api.webscrapingapi.com/v2" \
--data-urlencode "api_key=$WSA_API_KEY" \
--data-urlencode "url=https://example.com/public-page" \
--data-urlencode "json_response=1"import os
import requests
response = requests.get(
"https://api.webscrapingapi.com/v2",
params={
"api_key": os.environ["WSA_API_KEY"],
"url": "https://example.com/public-page",
"json_response": 1,
},
timeout=120,
)
response.raise_for_status()
print(response.json())const params = new URLSearchParams({
api_key: process.env.WSA_API_KEY,
url: "https://example.com/public-page",
json_response: "1",
});
const response = await fetch(
"https://api.webscrapingapi.com/v2?" + params,
{ signal: AbortSignal.timeout(120_000) }
);
if (!response.ok) throw new Error("API status " + response.status);
console.log(await response.json());<?php
$query = http_build_query([
"api_key" => getenv("WSA_API_KEY"),
"url" => "https://example.com/public-page",
"json_response" => 1,
]);
$client = curl_init("https://api.webscrapingapi.com/v2?" . $query);
curl_setopt_array($client, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
]);
$body = curl_exec($client);
$status = curl_getinfo($client, CURLINFO_RESPONSE_CODE);
$error = curl_error($client);
curl_close($client);
if ($body === false) throw new RuntimeException($error);
if ($status >= 400) throw new RuntimeException("API status " . $status);
echo $body;package main
import (
"fmt"
"io"
"net/http"
"net/url"
"os"
"time"
)
func main() {
params := url.Values{}
params.Add("api_key", os.Getenv("WSA_API_KEY"))
params.Add("url", "https://example.com/public-page")
params.Add("json_response", "1")
client := &http.Client{Timeout: 120 * time.Second}
response, err := client.Get(
"https://api.webscrapingapi.com/v2?" + params.Encode(),
)
if err != nil { panic(err) }
defer response.Body.Close()
if response.StatusCode >= 400 {
panic(fmt.Sprintf("API status %d", response.StatusCode))
}
body, err := io.ReadAll(response.Body)
if err != nil { panic(err) }
fmt.Println(string(body))
}import java.net.URI;
import java.net.URLEncoder;
import java.net.http.*;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
String query = "api_key=" + URLEncoder.encode(
System.getenv("WSA_API_KEY"), StandardCharsets.UTF_8
) + "&url=" + URLEncoder.encode(
"https://example.com/public-page", StandardCharsets.UTF_8
) + "&json_response=1";
var request = HttpRequest.newBuilder()
.uri(URI.create("https://api.webscrapingapi.com/v2?" + query))
.timeout(Duration.ofSeconds(120))
.GET().build();
var response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 400) {
throw new RuntimeException("API status " + response.statusCode());
}
System.out.println(response.body());using System.Net;
var apiKey = WebUtility.UrlEncode(
Environment.GetEnvironmentVariable("WSA_API_KEY")
);
var target = WebUtility.UrlEncode(
"https://example.com/public-page"
);
var requestUrl =
"https://api.webscrapingapi.com/v2?api_key=" + apiKey +
"&url=" + target + "&json_response=1";
using var client = new HttpClient();
client.Timeout = TimeSpan.FromSeconds(120);
var response = await client.GetAsync(requestUrl);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());require "net/http"
require "uri"
uri = URI("https://api.webscrapingapi.com/v2")
uri.query = URI.encode_www_form(
api_key: ENV.fetch("WSA_API_KEY"),
url: "https://example.com/public-page",
json_response: 1
)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.open_timeout = 10
http.read_timeout = 120
response = http.get(uri.request_uri)
raise "API status #{response.code}" unless response.is_a?(Net::HTTPSuccess)
puts response.body运营所有权
WebScrapingAPI
您的团队
Use the service only for eligible public webpages. Review source terms, applicable requirements, and the 服务协议, then apply appropriate request, retention, and data-use policies.
使用情况
产品选择
您操作HTTP客户端,请求政策,重试,解析和存储. WebScrapingAPI提供网络路线.
提供URL和请求选项. WebScrapingAPI操作检索并返回页面体或记录输出.
发送一个浏览器支持的REST请求,记录等待,交互,导航步骤和输出控制.
发送搜索参数,并从支持的搜索引擎收到结构化结果.
评估一个有限的多页集合,当工作单位不仅覆盖一个请求,而是涉及相关页面时.
查询支持的源,而WebScrapingAPI操作访问,target特定的提取和解析器维护.
定义源,方案,序列,质量和目的地,而WebScrapingAPI运行合同程序.
价格指导
自我服务评估
首先使用基本的HTTP路径,然后只测试你生产的控制器 target混合需要.
FAQ
抓取 API是一个服务器端请求终端点,它检索一个符合条件的公开网页,而 WebScrapingAPI则运行了请求背后的访问基础设施.您的应用程序提供URL和文档选项,然后收到所请求的页面响应.
默认响应是检索页面体. 文件选项可以返回一个JSON封面,一个JSON DOM表示,采集规则选择的字段,或您的应用程序稍后检索的异步结果.
是的. 设置 render_js=1 当一个页面需要客户端JavaScript执行,然后返回回响应. 使用浏览器 API当工作流需要文件文件浏览器交互,页面状态等待,点击或导航步骤.
抓取 API支持GET,POST,PUT和PATCH请求.当选择方法和target工作流程需要一个请求器时,包括一个请求器.
文件控制包括国家和支持城市,州或ASN文本.准确的可用性可能取决于当前的计划,地理和路线,因此确认您的工作负载所需的位置.
是的.客户提供的CSS或XPath提取规则可以返回选择的文本,HTML,属性,表,列表或嵌入式记录.您的团队拥有这些规则的选择器,方案,验证和源更改维护.
可以。使用文档中的异步选项将请求加入队列,保留返回的标识符,稍后将该标识符作为 snapshot_id 传入,即可获取已完成的结果。
检查记录的HTTP状态和错误体,适当时使用限度重试和退缩,并区分API故障与您的业务方案中存在但不完整的内容.