Headless Chrome
Puppeteer for Rust. It looks a little something like this:
use ;
assert!;
For fuller examples, take a look at tests/simple.rs
and examples/real_world.rs
.
If you're looking to do general browser testing or scraping (rather than anything specific to Chrome / DevTools), you're probably better off with fantoccini for now. It's a lot more feature-complete and stable.
Troubleshooting
If you get errors related to timeouts, you likely need to enable sandboxing either in the kernel or as a setuid sandbox. Puppeteer has some information about how to do that here
By default, headless_chrome
will download a compatible version of chrome to XDG_DATA_HOME
(or equivalent on Windows/Mac). This behaviour can be optionally turned off, and you can use the system version of chrome (assuming you have chrome installed) by disabling the default feature in your Cargo.toml
:
[]
= false
Missing features
- Frame / iframe support
window.alert
handlers- Frankly, most of what's possible using the Chrome DevTools Protocol
Contributing
Pull requests and issues are most welcome, even if they're just experience reports. If you find anything frustrating or confusing, let me know!