lorca
lorca copied to clipboard
Download Chromium if not already installed
Although in most cases Chrome/Chromium is already present, it might make sense to download the executable if it can not be found (for better user experience). Somehow https://github.com/puppeteer/puppeteer is able to do that (downloading portable chromium - https://github.com/puppeteer/puppeteer/blob/master/lib/BrowserFetcher.js). This would also fix #12
If there are any volunteers to implement this - I'd be happy to merge the PR ;)
Perhaps it seems a little strange, but to solve this I actually use zserge/webview and I ask it to open the url https://www.google.com/chrome/ .
In case anyone else gets ambitious, Puppeteer's files of interest:
- install.js
- BrowserFetcher.ts
- BrowserFetcher.js (might be mostly for experimental feature of getting Firefox)
One interesting question is how to deal with which version of Chromium should be installed? Puppeteer uses whatever's defined in package.json or whatever npm configuration is already given. I'm not sure if it makes the most sense to just get the latest version or if there should be a constant somewhere in lorca that defines what version of Chromium is currently supported (then manually incremented).
I could try, but please give a more sensible error message first,
log.Println("trying to launch")
w, err := lorca.New("", "", width, height)
if err != nil {
log.Fatal(err)
}
2020/08/31 14:46:34 trying to launch
2020/08/31 14:46:34 fork/exec : no such file or directory
exit status 1
BTW, I use Brave Browser (which there seems to be another issue here.)
I've been using Rod recently for browser automation which has this ability. His launcher library, which is the one downloading the browser, can be used as its own package.
https://github.com/go-rod/rod/tree/master/lib/launcher
By the way, I know this issue is quite old - but that error message comes from the executable not being found or incorrect permissions. Makes sense if you're using Brave - different executable path.
I could try, but please give a more sensible error message first,
log.Println("trying to launch") w, err := lorca.New("", "", width, height) if err != nil { log.Fatal(err) }2020/08/31 14:46:34 trying to launch 2020/08/31 14:46:34 fork/exec : no such file or directory exit status 1BTW, I use Brave Browser (which there seems to be another issue here.)