Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
私の生活を変えたHeadless Chrome / Headless Chrome who c...
Search
taminif
November 24, 2018
Programming
550
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
私の生活を変えたHeadless Chrome / Headless Chrome who changed my life
Nodefest 2018 LT
taminif
November 24, 2018
More Decks by taminif
See All by taminif
React Native New Architecture 移行実践報告
taminif
1
270
「とりあえずAI」が招く悲劇〜私がAIで生産性を下げるまでの話〜 / The tragedy caused by "AI for now" - The story of how I used AI to reduce my productivity
taminif
1
330
PuppeteerとPlaywrightの15日間の演劇 / relation of Puppeteer and Playwright
taminif
3
2.3k
Redashの開発はじめました / How to get started Redash development
taminif
0
820
WebSocketをiOSに持ち込んで辛い思いをした経験がありますか!? / have you painful experience in web socket?
taminif
3
6.3k
LINEで馬券を購入する / Purchase a betting ticket at LINE
taminif
1
1.7k
SkyWayで一年間運用してきたけどWebRTCってつらいんじゃないの
taminif
2
1k
オンライン英会話とSkyWay
taminif
0
560
オンライン英会話アプリとSkyWay
taminif
0
510
Other Decks in Programming
See All in Programming
変化を抱擁するドキュメントの作り方 - ビジネスルール駆動開発がもたらす、コードとの新しい関係
ioki
2
150
巨大モノリシックアプリ モダン化大作戦
ktcryomm
0
940
Jetpack Compose メカニズム
skydoves
0
140
型解析で実現する Go の言語内 DSL / Conference に Go! タイムテーブルの歩き方 for Gophers
mazrean
0
140
市販E-Readerを乗っ取れ 〜Embedded Swiftで電子ペーパーガジェットを制御する〜
trickart
0
180
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
360
デプロイ直後のレイテンシスパイクを調べたら、 Railsの仕様にたどり着いた
nhsykym
0
120
iOS開発×AI駆動開発 〜最近使って便利だったスキルの話〜
nogu66
0
150
LLMは4年分のCompose移行を再現できるのか?実プロダクト279件のXMLで探る自動化の境界線
makun
0
590
From 6 People Classroom Meetup to 100 People Regional Conference / FOSS4G Hiroshima 2026
furukawayasuto
0
140
AIは賢い。でも実行環境は? CLIおじさんがAI時代に伝えたいこと ~ CLIおじさんがAI時代に伝えたいこと ~
curekoshimizu
1
240
AI駆動開発にグラフDBを重ねてみた
satoshi256kbyte
2
790
Featured
See All Featured
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.2k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
440
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
480
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
sira's awesome portfolio website redesign presentation
elsirapls
0
410
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
390
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.9k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.9k
Paper Plane (Part 1)
katiecoart
PRO
1
11k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
410
Transcript
ࢲͷੜ׆Λม͑ͨ Headless Chrome ౦ژNodeֶԂࡇ2018 LT 2018/11/24 େౡ ޫو@sbntaminif
ࣗݾհ • ΣϒϦΦגࣜձࣾ։ൃάϧʔϓϦʔμʔ • ؔNodeֶԂओ࠵ • ීஈژͰಇ͍͍ͯ·͢ • ࠓ͜ΕͷҰ͠·ͤΜ↘
ಋೖ 3ϖʔδͰΓ·͢
1. ఆظߪೖΛࣗಈԽ͍ͨ͠ զ͕ՈͰ ࣗಈԽΛਪਐ ༻ͷങ͍ εʔύʔ Ͳ͏ʹ͔ࣗಈԽ ͍ͨ͠ Ͱ͖Εyodobashi.comͰങ͍͍ͨʢϙΠϯτͷͨΊʣ ՝
2. Amazon Dash Button ϘλϯΛԡ͚ͩ͢ͰAmazon͔Β͕ಧ͘
ʊਓਓਓਓਓਓਓਓਓਓਓਓਓਓʊ ʼɹ3. Yodobashi Dash Buttonɹʻ ʉY^Y^Y^Y^Y^Y^Y^Y^Y^Y^Yʉ
Ͳ͏͔ͬͨ
AWS IoT 1-Click Headless Chrome puppeteer
AWS IoT 1-Click ϘλϯΛԡ͢ͱAWSͰ࣮ߦ
AWS IoT 1-Click • Amazon Dash ButtonϋʔυΣΞΛϕʔεͱͨ͠ ϓϩάϥϛϯάՄೳͳϘλϯ • ͍ํAmazon
Dash Buttonͱಉ͡Ͱ ϘλϯΛԡͨ࣌͠ͷૢ࡞͕બΔ • ྨࣅσόΠεॱ࣍ൃച͍ͯ͠Δ • SORACOM LTE-M Button powered by AWSͳͲ
Headless Chrome https://developers.google.com/web/updates/2017/04/headless-chrome?hl=ja
Headless Chrome https://developers.google.com/web/updates/2017/04/headless-chrome?hl=en
Headless Chromeͱ • ChromeΛϔουϨεͰಈ࡞͢Δ • ϔουϨε = UIͳ͠Ͱ࣮ߦ • Chrome59͕Πϯετʔϧ͞Ε͍ͯΕ༻Մ
ೳʢWindows61ʣ • Chromeͷػೳ͕શͯ͑Δ
ͦͯ͠ Headless ChromeΛ ૢ࡞͢ΔͨΊʹ։ൃ͞Εͨ ϥΠϒϥϦ
puppeteer https://github.com/GoogleChrome/puppeteer
puppeteerͱ • Node.jsͰHeadless ChromeΛ ૢ࡞͢ΔϥΠϒϥϦ • Chrome DevToolsͷ্͔Βૢ࡞͢ΔAPI • GoogleChromeνʔϜ͕࣮
• ʮύϖςΟΞʯͱൃԻ
ಈ࡞ϨΠϠʔ
ChromeΛࣗಈͰಈ͔ͯ͠ ߪೖ·Ͱ ͨͲΓͭ͘
࣮͢Δ const puppeteer = require('puppeteer'); (async () => { const
browser = await puppeteer.launch({headless: true}); const page = await browser.newPage(); await page.setViewport({width: 640, height: 460}); await page.goto('https://order.yodobashi.com/yc/login/ index.html'); //////////////////////////////////////////// })(); $ISPNFΛىಈ ৽͍͠λϒΛ։͘ ΟϯυαΠζΛܾఆ 63-Λࢦఆͯ͠ભҠ
࣮͢Δ
࣮͢Δ //////////////////////////////////////////// await page.type('#memberId', '********'); await page.type('#password', '********'); page.click('#js_i_login0'); await
page.waitForSelector('#wrapper'); await page.goto('https://www.yodobashi.com/product/ 100000001002383900/'); //////////////////////////////////////////// ϩάΠϯใΛೖྗ ϩάΠϯϘλϯΛΫϦοΫ ભҠΛͭ 63-Λࢦఆͯ͠ભҠ
࣮͢Δ
͜Μͳײ͡Ͱ Ұͭͣͭૢ࡞ͯ͠ త·Ͱୡ͢Δ
࡞ͬͨͷ͕ͪ͜Β https://github.com/taminif/buyInYodobashi
εΫϦϓτΛ࣮ߦ͢Ε ͕ߪೖͰ͖ΔΑ͏ʹͳͬͨ
͜ΕΛAWS LambdaͰ ಈ͔͢
௨ৗͷpuppeteerΛ͏ͱ Chromium͕ೖΔ ͢ΔͱɺLambdaͷ༰ྔͰ͋Δ 50MBΛ͑Δ
serverless-chrome https://github.com/adieuadieu/serverless-chrome
ChromeΛLambdaͷ֎Ͱ ࣮ߦ͢Δ͜ͱͰ ༰ྔΦʔόʔΛճආ͢Δ
LambdaͰಈ͔ͨ͠ -BNCEBͰ ಈ࡞͢Δ"1* -BNCEBݺͼग़͠
Lambdaʹొ͢Δ͜ͱͰ ϘλϯΛԡͤߪೖͰ͖Δ!
⚠ൃੜ⚠
AWS Lambda͔Β yodobashi.comͷ ΞΫηε͕Ͱ͖ͳ͍ ϖʔδͷΈ 'PSCJEEFO
AWS͚ͩͳͷʁ ଞͷՈిྔൢళαΠτʁ ͜ΕΒͷ ࠙ձͰ͠·͠ΐ͏!
Ͳ͏ճආ͢Δ͔ Heroku͔ΒͳΒ ΞΫηεͰ͖Δ
ߏΛม͑Ε͍͚Δ -BNCEBݺͼग़͠ )5514௨৴Ͱ )FSPLVΛίʔϧ εΫϦϓτ࣮ߦ
Yodobashi Dash Button͕ ͨ͠!!
puppeteerͷັྗ
·ͣ͡Ίʹ Headless ChromeΛ্͢Ͱ ͔ܽͤͳ͍ಈը
The power of Headless Chrome https://www.youtube.com/watch?v=lhZOFUY1weo 2018ͷGoogle IOͷߨԋ
Headless Chrome େ͖ͳՄೳੑΛൿΊ͍ͯΔ
ࢲͷߟ͑Δ ࠷ັྗతͳٕज़
ͲΜͳWebαʔϏεͰ APIԽͰ͖Δ
Πϯλʔωοτશظ ϒϥβΛΘͳ͍ਓ ΄΅͍ͳ͍Ͱ͢ΑͶ
ීஈͷωοταʔϑΟϯΛ ࣗಈԽͰ͖Δ
ࣗಈԽͯ͠APIʹ͢Ε ͍ͭͰݺͼग़ͤΔ
APIԽ͓͚ͯ͠ ΠϯλʔϑΣʔε ͲΕͰ͑Δ ࠓͷεϚʔτεϐʔΧʔ ͰOK
⚠8BSOJOH
Ԭ࡚ࢢཱதԝਤॻؗࣄ݅ https://ja.wikipedia.org/wiki/Ԭ࡚ࢢཱதԝਤॻؗࣄ݅
Γ͗͢Δͱॻྨૹݕ·Ͱ ͋Γ·͢ ৗࣝతͳΞΫηεʹ ԡ͑͞·͠ΐ͏
͜ͷηογϣϯʹײԽ͞Εͯ ൃੜͨ͠ଛʹ͍ͭͯɺ ෛ͍݉Ͷ·͢
༻๏༻ྔΛकͬͯ ศརʹ͍·͠ΐ͏
͜ͷಈըͷதͰ ڧ͘͞Ε͍ͯΔ͜ͱ https://www.youtube.com/watch?v=lhZOFUY1weo
ʮ͜ͷςετࣗಈԽͷ Ͱ͋Γ·ͤΜʯ ʮࣗಈԽ͢Δ͜ͱ͕Ͱ͖Δʯ ʮࣗಈԽ͢ΔπʔϧͰ͋Δʯ
ීஈͷ࡞ۀΛࣗಈԽ͢Δ ͜Εͦ͜ΤϯδχΞϦϯά
ͬͯΈͨ͘ͳΓ·ͤΜ͔ʁ
ࣗಈԽ Έͳ͞ΜHeadless ChromeͰ ੜ׆Λม͍͖͑ͯ·͠ΐ͏ʂ
͋Γ͕ͱ͏͍͟͝·ͨ͠