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
350
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
Heart of Swift Concurrency
koher
0
1.2k
すこし踏み込む CancellationToken
htkym
2
1.6k
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
380
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
270
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
2
140
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
480
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.4k
RAG の “R” を Swift で覗いてみる 〜「意味から探す」検索の仕組み〜
nao_randd
0
120
Are APIs Still Relevant in the AI Era?
soyuka
0
440
残高管理から台帳サービスへの進化
artoy
0
180
contenteditable と日本語入力に向き合う
colorful12
0
170
AWSに止められる覚悟してますか?
morizo_1984
2
520
Featured
See All Featured
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
470
Chasing Engaging Ingredients in Design
codingconduct
0
350
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
530
Mobile First: as difficult as doing things right
swwweet
225
10k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
350
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.2k
A Tale of Four Properties
chriscoyier
163
24k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
300
Code Review Best Practice
trishagee
74
20k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
540
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
450
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Ͱ ੜ׆Λม͍͖͑ͯ·͠ΐ͏ʂ
͋Γ͕ͱ͏͍͟͝·ͨ͠