input schema proxy configuration
Hi guys, how to insert proxy configuration on my scraper?
INPUT SCHEMA:
{
"title": "PlaywrightCrawler Template",
"type": "object",
"schemaVersion": 1,
"properties": {
"startUrls": {
"title": "Start URLs",
"type": "array",
"description": "URLs to start with.",
"editor": "requestListSources",
"prefill": [
{
"url": "https://apify.com"
}
]
}
}
}
MAIN.JS:
import { Actor } from 'apify';
import { PuppeteerCrawler } from 'crawlee';
import { router } from './routes.js';
await Actor.init();
const input = await Actor.getInput();
const startUrls = input?.startUrls || [{ url: 'https://apify.com' }];
const proxyConfiguration = await Actor.createProxyConfiguration();
const crawler = new PuppeteerCrawler({
proxyConfiguration,
requestHandler: router,
});
await crawler.run(startUrls);
await Actor.exit();

4 Replies
helpful-purple•15mo ago
just use
as field in
properties
read it and pass into createProxyConfiguration
correct-apricot•15mo ago
Just as @Danek says, you can read more about handling inputs here: https://docs.apify.com/academy/getting-started/inputs-outputs
Inputs & outputs | Academy | Apify Documentation
Create an actor from scratch which takes an input, processes that input, then outputs a result that can be used elsewhere.
typical-coralOP•14mo ago
Hi, I want to use Apify Proxy with native Puppeteer JS. Is this the correct setup? Thanks in advance!
MAIN.JS:
const input = await Actor.getInput();
const { proxyConfiguration } = input;
const browser = await puppeteer.launch({
headless: "new",
proxy: proxyConfiguration
});
afraid-scarlet•13mo ago
Here is a good tutorial:
https://docs.apify.com/academy/puppeteer-playwright/proxies