20. $ chrome --headless --repl https://posobota.cz/
[0331/113150.981203:WARNING:dns_config_service_posix.cc(158)] dns_config has unhandled options!
[0331/113150.983272:ERROR:gpu_process_transport_factory.cc(1019)] Lost UI shared context.
[0331/113152.367207:INFO:headless_shell.cc(399)] Type a Javascript expression to evaluate or
"quit" to exit.
>>> location.href
{"result":{"type":"string","value":"https://www.posobota.cz/"}}
>>> quit
21. $ chrome --headless --print-to-pdf https://www.posobota.cz/
[0331/110056.799976:ERROR:gpu_process_transport_factory.cc(1019)] Lost UI shared context.
[0331/110056.799976:WARNING:dns_config_service_posix.cc(158)] dns_config has unhandled options!
[0331/110100.450183:INFO:headless_shell.cc(565)] Written to file output.pdf.
$ open output.pdf
22.
23. $ chrome --headless --print-to-pdf https://www.scuk.cz/faktury/xxx
[0331/110432.990656:ERROR:gpu_process_transport_factory.cc(1019)] Lost UI shared context.
[0331/110432.994518:WARNING:dns_config_service_posix.cc(158)] dns_config has unhandled options!
[0331/110434.655689:INFO:headless_shell.cc(565)] Written to file output.pdf.
$ open output.pdf
24.
25. $ chrome --headless --screenshot --window-size=1200x630
https://www.scuk.cz/og/obchod/antoninovo-pekarstvi
[0331/111345.000540:WARNING:dns_config_service_posix.cc(158)] dns_config has unhandled options!
[0331/111345.001073:ERROR:gpu_process_transport_factory.cc(1019)] Lost UI shared context.
[0331/111420.539961:INFO:headless_shell.cc(565)] Written to file screenshot.png.
~$ open screenshot.png
30. Spuštění Chrome
use ChromeDevtoolsProtocolContext;
use ChromeDevtoolsProtocolInstanceLauncher;
$ctx = Context::withTimeout(Context::background(), 10);
$launcher = new Launcher();
$instance = $launcher->launch($ctx);
try {
// ... work with $instance ...
} finally {
$instance->close();
}
31. Připojení se k existujícímu
use ChromeDevtoolsProtocolInstanceInstance;
$instance = new Instance("localhost", 9222);
// ... work with $instance ...