tim_coulter_95542
05/10/2025, 8:02 AMgotScraping library to retrieve the HTML from a set of YouTube video pages. The page URLs are passed as an input array.
typescript
await Actor.init();
const input = await Actor.getInput<Inputs>();
const store = await Actor.openKeyValueStore('html-page-store');
for (const url of input!.urls) {
log.info(`Fetching page HTML for video ID: ${url}`);
try {
const proxyConfiguration = await Actor.createProxyConfiguration({
groups: ['RESIDENTIAL'],
countryCode: 'US',
});
const proxyUrl = await proxyConfiguration!.newUrl();
log.info(`Using proxy URL:`, { proxyUrl });
const requestOptions = {
url,
proxyUrl,
headers: { ...Constants.defaultRequestHeaders }
};
const response = await gotScraping.get(requestOptions);
await store.setValue(url, response.body, {
contentType: 'text/html',
});
log.info(`Data extracted for video ID: ${url}`);
} catch (error) {
log.error(`Error extracting data for video ID: ${url}`, { error });
}
}
await Actor.exit();
When the actor runs, it correctly retrieves the first page in the sequence, but crashes when attempting to retrieve a different proxy for the second page (see attached screenshot)
What puzzles me is that the error does not get caught by the catch block in my own code; it seems to crash at a lower level.
I am also not clear why I am seeing the warning message WARN ProxyConfiguration: Apify Proxy access check timed out. and how to correct this issue. None of the docs seem to mention it.
Lastly, can you please clarify: if I want a different proxy for every request, should my call to Actor.createProxyConfiguration be inside the loop, or prior to the loop?
Hoping somebody can advise. Many thanks,
Tim
https://cdn.discordapp.com/attachments/1370672415591501825/1370672415792959569/image.png?ex=682059a9&is=681f0829&hm=bd4ff859ecdcf4b2820d7b859c287a3bc461335fcd403ebb691d0fc397a8558a&Hall
05/10/2025, 8:02 AMAnswer Overflow
05/10/2025, 8:03 AMazzouzana
05/10/2025, 10:39 AMtim_coulter_95542
05/11/2025, 7:11 AMApifyBot
05/11/2025, 7:11 AM