Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PuppeteerとPlaywrightの15日間の演劇 / relation of Pupp...
Search
taminif
February 12, 2020
Programming
2.3k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PuppeteerとPlaywrightの15日間の演劇 / relation of Puppeteer and Playwright
taminif
February 12, 2020
More Decks by taminif
See All by taminif
React Native New Architecture 移行実践報告
taminif
1
250
「とりあえずAI」が招く悲劇〜私がAIで生産性を下げるまでの話〜 / The tragedy caused by "AI for now" - The story of how I used AI to reduce my productivity
taminif
1
310
Redashの開発はじめました / How to get started Redash development
taminif
0
810
私の生活を変えたHeadless Chrome / Headless Chrome who changed my life
taminif
3
540
WebSocketをiOSに持ち込んで辛い思いをした経験がありますか!? / have you painful experience in web socket?
taminif
3
6.2k
LINEで馬券を購入する / Purchase a betting ticket at LINE
taminif
1
1.7k
SkyWayで一年間運用してきたけどWebRTCってつらいんじゃないの
taminif
2
1k
オンライン英会話とSkyWay
taminif
0
550
オンライン英会話アプリとSkyWay
taminif
0
500
Other Decks in Programming
See All in Programming
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
760
OSもどきOS
arkw
0
600
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
220
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
370
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
230
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
150
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
600
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
410
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.5k
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.5k
どこまでゆるくて許されるのか
tk3fftk
0
270
Inside Stream API
skrb
1
800
Featured
See All Featured
The Language of Interfaces
destraynor
162
27k
How to build a perfect <img>
jonoalderson
1
5.7k
Evolving SEO for Evolving Search Engines
ryanjones
0
230
Ruling the World: When Life Gets Gamed
codingconduct
0
270
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
380
GitHub's CSS Performance
jonrohan
1033
470k
Abbi's Birthday
coloredviolet
3
8.3k
So, you think you're a good person
axbom
PRO
2
2.1k
Designing for Timeless Needs
cassininazir
1
260
Utilizing Notion as your number one productivity tool
mfonobong
4
330
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
280
Information Architects: The Missing Link in Design Systems
soysaucechin
0
990
Transcript
PuppeteerͱPlaywrightͷ 15ؒͷԋܶ ؔNodeֶԂ 9࣌ݶ 2020/02/12 େౡ ޫو@sbntaminif
ࣗݾհ • ΣϒϦΦגࣜձࣾɹ։ൃGϦʔμʔ • ීஈژͰಇ͍͍ͯ·͢ • ۙگɹ໌͕ଉࢠͷ1ࡀͷੜͰ͢ ࠓ݄͔Βಋೖ͞Εͨه೦ٳՋͰ ໌͓ٳΈͰ͢
ϓϥΠϕʔτͰ։ൃ͢Δ͕࣌ؒ औΕ͍ͯͳ͍ࢲ͕ ٱ͠ͿΓʹPuppeteer͓͏ͱ ࢥͬͨ1݄15ͷग़དྷࣄ
2020/01/15
Microsoft EdgeͷChromium൛ ϦϦʔε https://support.microsoft.com/ja-jp/help/4501095/download-the-new-microsoft-edge-based-on-chromium
Puppeteer Chrome or ChromiumͰ ಈ࡞͢Δ
ಈ͘ͷ͔ݕূ͢Δ
const puppeteer = require('puppeteer'); (async () => { const browser
= await puppeteer.launch({ headless: false, // executablePath: '/Applications/Vivaldi.app/Contents/ MacOS/Vivaldi' executablePath: '/Applications/Microsoft Edge.app/ Contents/MacOS/Microsoft Edge' }); const page = (await browser.pages())[0] || (await browser.newPage()); ɾ ɾ ɾ EdgeͷύεΛࢦఆ FYFDVUBCMF1BUIΛࢦఆ͢Δ͜ͱͰ ҙͷϒϥβͰ࣮ߦ -> ͳ͘ಈ͍ͨ
READMEʹ هࡌ͕͋Δ https://github.com/puppeteer/puppeteer#default-runtime-settings
const puppeteer = require('puppeteer'); (async () => { const browser
= await puppeteer.launch({ headless: false, // executablePath: '/Applications/Vivaldi.app/Contents/ MacOS/Vivaldi' executablePath: '/Applications/Microsoft Edge.app/ Contents/MacOS/Microsoft Edge' }); const page = (await browser.pages())[0] || (await browser.newPage()); ɾ ɾ ɾ Vivaldiͪΐͬͱ͚ͩڍಈ͕ҧ͏ 7JWBMEJΛࢦఆͨ࣌͠ ʮελʔτϖʔδʯ͕͋Δঢ়ଶʢϒϥβىಈޙʣ CSPXTFSOFX1BHF ͢Δͱ݁Ռ͕ฦͬͯ͜ͳ͍ λϒ͕ଘࡏ͢Δ߹ͦͷλϒΛ͏͜ͱͰରԠ ʮελʔτϖʔδʯͰͳ͚ΕOFX1BHF ͰλϒΛ૿ͤΔ
MicrosoftެࣜDocsʹ Puppeteerͷϖʔδ͕Ͱ͖ͯΔ https://docs.microsoft.com/en-us/microsoft-edge/puppeteer
EdgeͰಈ͔͢ํ๏·Ͱ͋Δ https://docs.microsoft.com/en-us/microsoft-edge/puppeteer
͜ͷ࣌EdgeͰ ͍Ζ͍Ζ༡ͿͭΓͩͬͨ
Ұिؒޙʹ ಥݱΕͨPlaywright
2020/01/23
Playwright https://github.com/microsoft/playwright
Playwrightͱ • Chromium, Firefox, WebkitΛಈ͔͢ NodeϥΠϒϥϦ • ϔουϨεϞʔυՄೳ • Microsoft͔Βఏڙʢͨͩ͠·ͩVersion0.10.0ʣ
• It enables cross-browser web automation that is ever-green, capable, reliable and fast.
Puppeteerͱ Ͳ͏ҧ͏ͷ͔ʁ
࠷ॳPuppeteerͱಉ͡νʔϜ ಉ͡APIͱઆ໌͞Ε͍ͯͨ https://github.com/microsoft/playwright/tree/f03b64860f64e05e1e8bb41a952e999dbdf6b150#faq
2020/01/29
Puppeteer v2.1.0 ϦϦʔε
ެࣜͰFirefoxΛαϙʔτ https://twitter.com/mathias/status/1222183802870607872 'JSFGPYͰ1VQQFUFFS͕ ಈ͘Α͏ʹͳΓ·ͨ͠
͜ͷπΠʔτʹ࣭͕ࡴ౸ https://twitter.com/mathias/status/1222183802870607872
ಛʹ͜ͷπΠʔτ https://twitter.com/mathias/status/1222189671389835269 -> ͦΕͧΕผͷνʔϜͰ։ൃ -> Google͜Ε͔ΒPuppeteerΛαϙʔτ
͞Βʹ͜ͷπΠʔτ https://twitter.com/benedyktdryl/status/1222196512144416768 ͜͜ͰผνʔϜͰ͋Δ͜ͱ͕Θ͔Δ
͞Βʹ͞Βʹ͜ͷπΠʔτ https://twitter.com/kentcdodds/status/1222199111341838336 ͜͜ͰνʔϜ͕Ҡಈͨ͜͠ͱ͕Θ͔Δ
2020/01/28
Yang Guo͕READMEʹه https://github.com/microsoft/playwright/pull/711/files
ಥʹ໊લग़ͨ͠ͷͰ https://twitter.com/malfaitrobin/status/1222199209761345536 :BOH(VP ͜ͷਓͰ͢ :BOH(VP ͜ͷਓͰ͢ ͲͪΒ (PPHMFS
InfoQ͔͠هࣄ͕ݟ͔ͭΒͳ͍ t ͜͜Ͱͷ"OOPVODFT (JUIVCͷ͜ͱͬΆ͍
Microsoft͔ΒGoogle͔Β هࣄ͕ग़͍ͯͳ͍ͷͰ ެࣜใͪͰ͢
Playwright ͬͯΈͨ
const { firefox, webkit, chromium } = require("playwright"); const loginPageUrl
= 'https://order.yodobashi.com/yc/login/ index.html'; (async () => { // const browser = await webkit.launch(); // const browser = await chromium.launch({headless: false}); const browser = await firefox.launch({dumpio: true}); const context = await browser.newContext(); const page = await context.newPage(); await page.setViewport({width: 1920, height: 2000}); await page.goto(loginPageUrl, { waitUntil: 'networkidle2', }); ɾ ɾ ɾ ΄΅Puppeteerͱಉ͡ίʔυͰಈ͍ͨ 8FCLJUͷ߹ $ISPNJVNͷ߹ 'JSFGPYͷ߹ 1VQQFUFFSͱҧ͏෦
ಈ͔ͳ͍෦͋Δ FirefoxͰwaitForSelector͕ ಈ͔ͳ͍ ʢࣗͷௐࠪෆ͔͠Εͳ͍ʣ
2020ͷϝδϟʔϦϦʔε͕ ظ͞Ε͍ͯΔ (͜ΕInfoQͷΈ)
ͦͯ͠Puppeteer ։ൃଓ͘
ͲͪΒΩϟονΞοϓͯ͠ ͍͖ͬͯ·͠ΐ͏ʂ
͋Γ͕ͱ͏͍͟͝·ͨ͠