impression of google chrome headless

impression of google chrome headless

F3ba76698a3a2ea827abd7b73d74a5b7?s=128

teitei_tk

May 31, 2017
Tweet

Transcript

  1. ChromeHeadless modeΛ৮ͬͨॴײ 2017/05/31 @teitei_tk

  2. ࣗݾ঺հ • @teitei_tk • ࠷ۙ͸ϋΠϥϧԦࠃΛฏ࿨ʹ͢ΔͨΊʹؤுͬ ͯ·͢ɻ

  3. ຊ୊

  4. ͷલʹ

  5. Chrome Headless ͱ͸ʁ

  6. ͍ΘΏΔHeadlessϒϥ΢β • ޡղΛঝ஌Ͱݴ͑͹ɺGUIͷແ͍Chromeɻ • GUI͸ͳ͍͕ɺ಺෦తʹ͸ϖʔδͷϨϯμϦϯά ͔ΒJavaScriptͷ࣮ߦ౳ɺϒϥ΢βͬΆ͍͜ͱ͕ Ͱ͖Δ

  7. Ͳ͏͍͏༻్͕͋Δͷ • WebApplicationͷςετ • ͍ΘΏΔE2E • WebPageͷΩϟϓνϟࡱӨ • WebαΠτͷεΫϨΠϐϯά •

    DDoS߈ܸ
  8. ͳͥ Chrome Headless͔

  9. PhantomJSͷࢮ๢

  10. PhantomJSͱ͸ • Headlessϒϥ΢βͷҰͭ • ͓ͦΒ͘Ұ൪ਓؾ͕͋ΔͷͰ͸ͳ͍ͩΖ͏͔ • ͔͠͠ɺ2017/05/30ݱࡏͰissue͸1848ɺPull Request͸58ͱ։ൃ͸ఀ଺͍ͯ͠Δ • https://github.com/ariya/phantomjs/

  11. PhantomJS is Dead • ͦͯ͠།Ұͷϝϯςφ͕ࠓޙ͸ΈͳChrome Headlessʹ ৐Γ׵͑ΔͩΖ͏ͱϝϯςφΛࣙ೚Λએݴɻ • https://groups.google.com/d/msg/phantomjs/9aI5d- LDuNE/5Z3SMZrqAQAJ

    • ࠓޙͷߏ૝͸͋Δͷ͔ɺphantomiumͱ͍͏PhantomJS + ChromeHeadlessͷ୯ޠ͕૊Έ߹Θͬͨ͞ϨϙδτϦ͸͋ Δ • https://github.com/Vitallium/phantomium
  12. ͱ͍͏ͷ͕എܠ

  13. Կނ Chrome Headless͔

  14. • Google͕։ൃ͍ͯ͠Δͱ͍͏҆৺ײ • Webඪ४΁ͷ४ڌ͕ૣ͍ͷͰɺ͍ͪૣ͘ػೳ͕࢖͑Δɻ • ֤छAPIͷར༻͕Մೳ • ServiceWorker • IndexedDB

    • Memory Heap Profiler • etc
  15. ͱ͍͏Θ͚Ͱ ৮ͬͯΈͨ

  16. Setup • Chrome Ver59Ҏ͕߱ඞਢ • ݱࡏ(2017/05/30)ͷChromeͷStable Version͸58 • Chrome CanaryΛ࢖͏ͱྑͦ͞͏

  17. ؆୯ͳ΋ͷͳΒ͙͢ग़དྷΔ • ShellͰ͙͢ग़དྷΔ • DOMͷग़ྗ • PDF࡞੒ • Ωϟϓνϟͷऔಘ •

    eg. $ chrome --headless --disable-gpu --dump- dom https://www.chromestatus.com/
  18. ద౰ʹWrapperॻ͍ͨ • ΩϟϓνϟͷࡱӨ • https://wobfnz0lh2.execute-api.us- west-2.amazonaws.com/dev/chrome?url=https:// google.co.jp • PDFͷੜ੒ •

    https://wobfnz0lh2.execute-api.us- west-2.amazonaws.com/dev/pdf?url=https:// google.com/
  19. • ݴޠɿNode.js • ओʹ࢖༻ͨ͠ϥΠϒϥϦ • chrome-remote-interface • ChromeͷAPIΛୟ͘Node.jsϥΠϒϥϦ • lighthouse

    • ChromeΛىಈ͢Δϔϧύʔ͕هࡌ͞Ε͍ͯΔ ϥΠϒϥϦ
  20. ॴײ • ҆ఆԽ·Ͱ͸΋͏গֻ͔͠Γͦ͏ɻ • Ṗͷ--disable-gpu Option • API͕·ͩམͪண͍͍ͯͳ͍ͷͰຊ൪౤ೖ͸·ͩආ͚ͨ΄͏ ͕ྑͦ͞͏ •

    ͱ͸͍͑PhantomJSͷޙ佂ʹ͸࠲Γͦ͏ɻ • ಈ޲͸௥͓͖ͬͯ·͢ɻ • Կ͔͋ͬͨΒهࣄͰ΋ॻ͍ͯڞ༗͠·͢ɻ