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
560
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
290
「とりあえずAI」が招く悲劇〜私がAIで生産性を下げるまでの話〜 / The tragedy caused by "AI for now" - The story of how I used AI to reduce my productivity
taminif
1
340
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
WebRTC映像をAirPlayに対応させる挑戦.pdf
monolithic_adam
0
340
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.5k
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
20
21k
カツオ、ご期待ください
suneo3476
0
150
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
2
130
Java 27新機能 / Java 27 new features
kishida
2
200
wkhtmltopdfの次どうするか問題2026
willnet
2
1.8k
速習iPhone Duo対応
yuukiw00w
2
960
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2.8k
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.5k
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
130
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
Featured
See All Featured
Darren the Foodie - Storyboard
khoart
PRO
4
4k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
790
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Fireside Chat
paigeccino
43
4k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
How to make the Groovebox
asonas
2
2.5k
[SF Ruby Conf 2025] Rails X
palkan
3
1.4k
Faster Mobile Websites
deanohume
310
32k
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Ͱ ੜ׆Λม͍͖͑ͯ·͠ΐ͏ʂ
͋Γ͕ͱ͏͍͟͝·ͨ͠