You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel hotrush/Webshotter持续报页面加载超时错误求助

Troubleshooting "page load timeout" When Capturing Screenshots with Webshot

Hey there, let's work through why you're hitting that "page load timeout" error while trying to capture baidu.com using webshot. I’ve run into similar headaches before, so here are some practical angles to check:

  • Anti-scraping measures might be blocking your request
    Sites like Baidu often flag automated tools like webshot and throttle or block their access. A quick fix is to mimic a real browser’s user agent to bypass basic detection. Add this line to your code:
    ->setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36')

  • Timeout settings might need a tweak
    Even with a 45-second timeout, dynamic pages like Baidu can take longer to fully render all their content. Try bumping the main timeout to 60 or 90 seconds first. You can also temporarily disable waitForImages() to see if the page loads without waiting for every asset—this will help rule out slow-loading images causing the hang.

  • Check server connectivity and proxy setup
    If your server is behind a proxy, webshot might not be configured to use it, leading to slow or failed connections. Run curl https://baidu.com from your server to confirm it can reach the site quickly. If you need a proxy, look into webshot’s proxy configuration options to set that up.

  • Update webshot to the latest version
    Older versions of the library might have bugs related to page loading timeouts. Updating to the most recent release could resolve the issue outright.

Here’s a modified version of your code with some of these adjustments:

$jpg = $webshot
    ->setUrl('https://baidu.com/')
    ->setWidth(1200)
    ->setHeight(800)
    ->setTimeout(60) // Extended main timeout
    ->setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36')
    ->setFullPage(false)
    ->waitForImages()
    ->setImagesLoadingTimeout(180)
    ->saveToPng('baidu_full', 'myimages/');

If none of these work, enable webshot’s debug mode to get detailed logs—this will show you exactly which resource is hanging and causing the timeout.

内容的提问来源于stack exchange,提问作者fengnan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:45:51