Seeking a JavaScript-enabled headless browser for Android devices

Hey everyone,

I’m trying to find a headless browser that works on Android and can handle JavaScript. So far, I’ve had no luck.

I gave HTMLUnit a shot, but it’s not compatible with Android. Then I tried JSoup, which runs smoothly on Android, but it can’t process JavaScript.

Does anyone know of other options I could try? I really need something that can work on Android and handle JS.

I’d be super grateful for any suggestions or recommendations. Thanks in advance for your help!

I’ve been down this road before, and I found that Selenium WebDriver with ChromeDriver actually works quite well on Android. It’s not strictly headless, but you can configure it to run in headless mode.

To set it up, you’ll need to include the Selenium WebDriver library in your Android project and download the appropriate ChromeDriver for Android. Then, you can create a ChromeDriver instance with headless options.

One thing to keep in mind is that you’ll need to run this on a rooted device or emulator, as ChromeDriver requires root access on Android. It’s a bit of a hassle to set up initially, but once you’ve got it working, it’s pretty reliable for executing JavaScript and scraping content.

If you’re looking for something lighter, you might want to check out Rhino as well. It’s not a full browser, but it can execute JavaScript within your Android app.

Have you considered using WebView in Android? It’s a built-in component that can render web pages and execute JavaScript. You can use it in headless mode by creating an invisible WebView instance.

To implement this, you’d need to set up a WebView in your Android app, load the desired URL, and then use evaluateJavascript() to run your JS code. You can retrieve the results through a callback.

It’s not a perfect solution, as it’s not truly headless, but it’s a workaround that might suit your needs. Plus, it’s native to Android, so you won’t face compatibility issues.

If that doesn’t work for you, you might want to look into running a Node.js server on Android and using puppeteer-core. It’s more complex to set up, but it offers full headless browser capabilities.

hey have u tried phantomjs? it’s a headless browser that supports js and can run on android. u might need to compile it for android tho. another option is rhino, a js engine for java that works on android. it’s not a full browser but can execute js code. hope this helps!