Products / Web Scraping API
Cloud Storage
Send async job results straight to a bucket you control.
Destinations
| Destination | storage_type | storage_url format |
|---|---|---|
| Amazon S3 | s3 | YOUR_BUCKET/YOUR_PREFIX |
| Google Cloud Storage | gcs | YOUR_BUCKET/YOUR_PREFIX |
| S3-compatible | s3_compatible | https://ACCESS_KEY:SECRET@HOST/BUCKET_OR_PREFIX |
| BytePlus TOS | tos | https://ACCESS_KEY:SECRET@ENDPOINT/BUCKET/PATH |
Submit a job
Add storage_type and storage_url to a job sent to your async URL. Cloud storage works with Push-Pull jobs only, not Realtime.
curl -X POST ASYNC_URL \
-u "USERNAME:PASSWORD" \
-H "Content-Type: application/json" \
--max-time 180 \
-d '{"source":"universal","url":"https://example.com/","storage_type":"s3","storage_url":"YOUR_BUCKET/collection"}'import requests
payload = {
"source": "universal",
"url": "https://example.com/",
"storage_type": "s3",
"storage_url": "YOUR_BUCKET/collection"
}
response = requests.post(
"ASYNC_URL",
auth=("USERNAME", "PASSWORD"),
json=payload,
timeout=180,
)
print(response.json())const payload = {
"source": "universal",
"url": "https://example.com/",
"storage_type": "s3",
"storage_url": "YOUR_BUCKET/collection"
};
const res = await fetch("ASYNC_URL", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Basic " + Buffer.from("USERNAME:PASSWORD").toString("base64"),
},
body: JSON.stringify(payload),
signal: AbortSignal.timeout(180000),
});
console.log(await res.json());<?php
$payload = '{"source":"universal","url":"https://example.com/","storage_type":"s3","storage_url":"YOUR_BUCKET/collection"}';
$ch = curl_init("ASYNC_URL");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_USERPWD => "USERNAME:PASSWORD",
CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
CURLOPT_POSTFIELDS => $payload,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 180,
]);
echo curl_exec($ch);package main
import (
"bytes"
"fmt"
"io"
"net/http"
"time"
)
func main() {
payload := []byte(`{"source":"universal","url":"https://example.com/","storage_type":"s3","storage_url":"YOUR_BUCKET/collection"}`)
req, _ := http.NewRequest("POST", "ASYNC_URL", bytes.NewReader(payload))
req.SetBasicAuth("USERNAME", "PASSWORD")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{Timeout: 180 * time.Second}
resp, err := client.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}import java.net.URI;
import java.net.http.*;
import java.time.Duration;
import java.util.Base64;
public class Main {
public static void main(String[] args) throws Exception {
String payload = """
{
"source": "universal",
"url": "https://example.com/",
"storage_type": "s3",
"storage_url": "YOUR_BUCKET/collection"
}
""";
String auth = Base64.getEncoder().encodeToString("USERNAME:PASSWORD".getBytes());
HttpRequest req = HttpRequest.newBuilder(URI.create("ASYNC_URL"))
.header("Content-Type", "application/json")
.header("Authorization", "Basic " + auth)
.timeout(Duration.ofSeconds(180))
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
System.out.println(HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString()).body());
}
}using System.Net.Http.Headers;
using System.Text;
var payload = """
{
"source": "universal",
"url": "https://example.com/",
"storage_type": "s3",
"storage_url": "YOUR_BUCKET/collection"
}
""";
using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(180) };
var auth = Convert.ToBase64String(Encoding.UTF8.GetBytes("USERNAME:PASSWORD"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", auth);
var res = await client.PostAsync("ASYNC_URL",
new StringContent(payload, Encoding.UTF8, "application/json"));
Console.WriteLine(await res.Content.ReadAsStringAsync());require "net/http"
require "json"
uri = URI("ASYNC_URL")
req = Net::HTTP::Post.new(uri, "Content-Type" => "application/json")
req.basic_auth("USERNAME", "PASSWORD")
req.body = {
"source" => "universal",
"url" => "https://example.com/",
"storage_type" => "s3",
"storage_url" => "YOUR_BUCKET/collection"
}.to_json
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true, read_timeout: 180) do |http|
http.request(req)
end
puts res.bodyPermissions
- S3: give the service principal assigned to your account permission to upload to the prefix.
- GCS: give the assigned service account permission to create objects.
- URL-encode special characters in keys and secrets in S3-compatible URLs, and keep those URLs out of logs.
- Alibaba OSS needs a folder, not the bucket root.
Check the upload
Check statuses even when the job is done: 13000 success, 13001 failure, 13102 path not found, 13103 access denied.