Scraping Service
Run scraping tasks using pre-built scrapers. Create tasks, poll for results, or use the synchronous scrape method.
Methods
scrape(request)
Run a scraping task and wait for the result (synchronous).
const result = await client.scraping.scrape({
actor: 'scraper.google.search',
input: { q: 'web scraping' },
});createTask(request)
Create a scraping task without waiting for the result.
const task = await client.scraping.createTask({
actor: 'scraper.google.search',
input: { q: 'web scraping' },
});
console.log(task.data.taskId);getTaskResult(taskId)
Get the result of a previously created task.
const result = await client.scraping.getTaskResult(task.data.taskId);Request Type
interface ScrapingTaskRequest {
actor: string; // Scraper ID (e.g. 'scraper.google.search')
input: Record<string, unknown>; // Scraper input data
proxy?: {
country?: string;
type?: 'residential' | 'datacenter' | 'ipv6';
};
}Response Types
interface ScrapingTaskResponse {
taskId: string;
status: 'pending' | 'running' | 'success' | 'failed';
createdAt?: string;
}
interface ResponseWithStatus<T> {
status: number;
data: T;
}Example with Proxy
const result = await client.scraping.scrape({
actor: 'scraper.google.search',
input: { q: 'best restaurants in NYC' },
proxy: {
country: 'US',
type: 'residential',
},
});