最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

node.js - Crawling a page in Laravel 11 with spatie browsershot works from command but not directly from url in server - Stack O

programmeradmin1浏览0评论

I have set a crawling command that works in local as well as in live using Laravel 11 and spatie browsershot. But when running directly from a url and cron in server following error occurs. I am using latest node version v23.9.0

vendor/spatie/browsershot/bin/browser.cjs:104 protocolTimeout: request.options.protocolTimeout ?? 30000,^ SyntaxError: Unexpected token '?'

Tried in locally which works but not in server from url and cron. My main code using package:

$browsershot = Browsershot::url($url)
                ->waitUntilNetworkIdle(true, 1000) // Increase to 1s for better stability
                ->userAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36')
                ->timeout($waitTime) // Increase timeout to 3 minutes
                ->setOption('args', [
                    '--no-sandbox',
                    '--disable-dev-shm-usage',
                    '--disable-setuid-sandbox',
                    '--ignore-certificate-errors',
                    '--disable-background-timer-throttling',
                    '--disable-backgrounding-occluded-windows'
                ])
                ->ignoreHttpsErrors()
                ->dismissDialogs();

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论