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
240
「とりあえず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
関係性から理解する"同一性"の型用語たち
pvcresin
2
640
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
13
3.5k
LLM Plugin for Node-REDの利用方法と開発について
404background
0
160
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
650
tsserverとは何だったのか、これからどうなるのか
nowaki28
1
450
CLIであることを活かしたGitHub Copilot CLI活用術 / GitHub Copilot CLI Pro Tips & Tricks
nao_mk2
1
1.2k
AIで効率化できた業務・日常
ochtum
0
100
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
140
AIとRubyの静的型付け
ukin0k0
0
540
AIとASP.NET Coreで雑Webアプリを作った話
mayuki
0
380
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
300
肥大化するレガシーコードに立ち向かうためのインターフェース分離と依存の逆転 / JJUG CCC 2026 Spring
hirokunimaeta
0
500
Featured
See All Featured
Discover your Explorer Soul
emna__ayadi
2
1.1k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
840
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Exploring anti-patterns in Rails
aemeredith
3
400
YesSQL, Process and Tooling at Scale
rocio
174
15k
Evolving SEO for Evolving Search Engines
ryanjones
0
210
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
520
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.5k
Color Theory Basics | Prateek | Gurzu
gurzu
0
360
A Soul's Torment
seathinner
6
2.9k
Heart Work Chapter 1 - Part 1
lfama
PRO
7
36k
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 ։ൃଓ͘
ͲͪΒΩϟονΞοϓͯ͠ ͍͖ͬͯ·͠ΐ͏ʂ
͋Γ͕ͱ͏͍͟͝·ͨ͠