4 ms·
What would you do with this solution Automate the browser that can’t already be done I did not say it can't be done now. But I don't want the overhead of
by TicklishTiger 8y ago
What would you do with this solution
Automate the browser
that can’t already be done
I did not say it can't be done now. But I don't want the overhead of pupeteer, selenium plus the client libraries to control them. These things are fricking monsters. And they will go out of fashion at some point. Simple javascript commands will not.
with headless browsers
I don't want headless. I just want to automate.
- phiresky 8y agoYou can run puppeteer with any chromium binary, including non-headless mode. You can also just start chromium with debugging active `--remote-debugging-port=9222` and then connect to that port and send any dev console commands.
- TicklishTiger 8y agoHow do you send dev console commands to that port?
- phiresky 8y agoIt uses the devtools protocol, see here https://chromedevtools.github.io/devtools-protocol/ https://chromedevtools.github.io/devtools-protocol/ Looks like it's a REST protocol. You have to connect to a tab and then call e.g. Runtime.evaluate {expression: "console.log('test')"}
- phiresky 8y agoAlso, you can apparently connect the puppeteer client to a running chrome instance [1]. That way you can use the nice and statically typed puppeteer api and you should have pretty much zero overhead. [1] https://github.com/GoogleChrome/puppeteer/issues/238 https://github.com/GoogleChrome/puppeteer/issues/238
- matthewmacleod 8y agoBut I don't want the overhead of pupeteer I don't understand this objection. Puppeteer is the client library that you want, and it's not particularly massive. It's the plumbing to handle all of the stuff around starting and connecting to browsers, providing a tidy API to abstract the stuff that's annoying to use directly. In fact, you can do almost anything you want to using the existing interface that Chrome has built in: chromium --remote-debugging-port=9222 You can connect to it using e.g. the WS command line tool using the URL it spits out: ws ws://127.0.0.1:9222/devtools/browser/81b9b178-ece0-4953-8ea0-bce6ac31d89c Then you can make it do things: {"id": 1, "method": "Target.createTarget", "params": {"url": "http://www.google.com"}} It does what you want, over a web socket interface rather than HTTP.
- TicklishTiger 8y agoThat looks interesting. Where does that ws tool come from? Is it this one? https://packages.debian.org/stretch/node-ws https://packages.debian.org/stretch/node-ws How do you send javascript commands over that protocol?
- deleted 8y ago[deleted]