interface InputSchema { startUrls: string[], } // ... const input = await Actor.getInput<InputSchema>(); // input.startUrls is type of string[]
await crawler.run([ { url: startUrls, label: "companyInfo", }, ]);
const input = (await Actor.getInput()) as Record<string, any>;
var companyWebsites = input.companyWebsites as Array<string>;
as
operator when it is not necessary.interface InputSchema { startUrls: string[], } // ... const input = await Actor.getInput<InputSchema>(); // input.startUrls is type of string[] await crawler.run(input.startUrls.map((startUrl) => ({ url: startUrl, label: "companyInfo", })));
await Actor.main(async () => { const crawler = new PlaywrightCrawler({ requestHandler: router, }); await crawler.run( companyWebsites.map((startUrl) => ({ url: startUrl, label: "companyInfo", })) ); });
{ "runMode": "PRODUCTION", "companyWebsites": [ "shopwagandtail.com", "trustpilot.com" ], "sortBy": "recency", "filterByStarRating": "5", "filterBylanguage": "en", "filterByVerified": "yes", "startFromPageNumber": "2", "endAtPageNumber": "3" }
`Error: Input schema is not a valid JSON (SyntaxError: Unexpected token } in JSON at position 458)
await crawler.run( companyWebsites.map((startUrl) => ({ url: startUrl.url, label: "companyInfo", })) ); });
companyWebsites
should be array of objects: "companyWebsites": [{ url: "shopwagandtail.com" }, { url: "trustpilot.com"}],
input_schema.json
requires the format with objects:"editor": "requestListSources",
"editor": "json"
"editor": "requestListSources",
await crawler.run( companyWebsites.map((startUrl) => ({ url: startUrl.url, label: "companyInfo", // sets the label })) ); });