scrapinghub / splash

Lightweight, scriptable browser as a service with an HTTP API
BSD 3-Clause "New" or "Revised" License
4.04k stars 507 forks source link

Splash doesn't render React single-page application #1182

Open Azaze1l opened 10 months ago

Azaze1l commented 10 months ago

Hey!

I'm trying to render this https://app.adapty.io/login page but facing some strange behavior. I'm getting a blank white page as a response:

Screenshot 2023-08-18 at 15 19 22

My lua function:

function main(splash, args)
  splash.private_mode_enabled = false
  splash:set_viewport_full()
  splash:set_user_agent('Mozilla/5.0 (Windows NT 6.1; rv:51.0) Gecko/20100101 Firefox/51.0')
  assert(splash:go(args.url))
  assert(splash:wait(60))
  return {
    html = splash:html(),
    png = splash:png(),
    har = splash:har(),
  }
end

After doing some research I've found some interesting related to my problem reports: React website showing a blank white page and no content

Scrapy-splash not rendering dynamic content from a certain react-driven site

But there is still no context here.

Should I keep trying to use Splash as a rendering service or it can be a better option to use something different? Does anyone have a guess why this happens with React apps?

SardarDelha commented 10 months ago

Splash cannot render single page applications. In fact, Splash only receives the view source and does not understand the html that is created by JavaScript. We used to use Splash before, but because it is no longer updated and also does not support SPA, we use playwright. Playwright is both simple and can be used in Python.

Azaze1l commented 9 months ago

@SardarDelha thank you a lot for the alternative solution!