{"id":52272,"date":"2017-08-21T08:28:45","date_gmt":"2017-08-20T23:28:45","guid":{"rendered":"http:\/\/www.softantenna.com\/wp\/?p=52272"},"modified":"2017-08-21T08:28:45","modified_gmt":"2017-08-20T23:28:45","slug":"puppeteer","status":"publish","type":"post","link":"https:\/\/softantenna.com\/blog\/puppeteer\/","title":{"rendered":"Puppeteer - Chrome DevTools\u306b\u3088\u308b\u30d8\u30c3\u30c9\u30ec\u30b9Chrome\u3092\u64cd\u4f5c\u3059\u308b\u305f\u3081\u306eNode API"},"content":{"rendered":"<p><img decoding=\"async\" style=\"display:block; margin-left:auto; margin-right:auto;\" src=\"https:\/\/softantenna.com\/blog\/wp-content\/uploads\/2017\/08\/Is_20170818_161733.jpg\" alt=\"S 20170818 161733\" title=\"s_20170818_161733.jpg\" border=\"0\" width=\"903\" height=\"609\" \/><\/p>\n<p>Google\u306fChrome 59\u3067(macOS or Linux\u7248)\u3001\u30d6\u30e9\u30a6\u30b6\u3092\u30d8\u30c3\u30c9\u30ec\u30b9\u74b0\u5883\u3067\u5b9f\u884c\u3067\u304d\u308b\u300c<a href=\"https:\/\/developers.google.com\/web\/updates\/2017\/04\/headless-chrome?hl=ja\">\u30d8\u30c3\u30c9\u30ec\u30b9Chrome<\/a>\u300d\u3068\u547c\u3070\u308c\u308b\u6a5f\u80fd\u3092\u5c0e\u5165\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u81ea\u52d5\u30c6\u30b9\u30c8\u74b0\u5883\u3084\u30b5\u30fc\u30d0\u30fc\u74b0\u5883\u3067\u6d3b\u7528\u3067\u304d\u308b\u958b\u767a\u8005\u5411\u3051\u306e\u6a5f\u80fd\u3067\u3001\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u3084Web\u30da\u30fc\u30b8\u306e\u753b\u50cf\u306e\u53d6\u5f97\u3068\u3044\u3063\u305f\u3055\u307e\u3056\u307e\u306a\u64cd\u4f5c\u304cGUI\u306a\u3057\u3067\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u7d39\u4ecb\u3059\u308b\u300c<a href=\"https:\/\/github.com\/GoogleChrome\/puppeteer\">Puppeteer<\/a>\u300d\u306f\u3053\u306e\u30d8\u30c3\u30c9\u30ec\u30b9Chrome\u3092\u3055\u3089\u306b\u4f7f\u3044\u3084\u3059\u304f\u3059\u308b\u305f\u3081\u306eNode\u7528\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002<\/p>\n<p>Chrome DevTools\u30c1\u30fc\u30e0\u304c\u4fdd\u5b88\u3057\u3066\u3001DevTools Protocol\u3092\u5229\u7528\u3057\u3066\u30d8\u30c3\u30c9\u30ec\u30b9Chrome\u3092\u7c21\u5358\u306b\u64cd\u4f5c\u3059\u308b\u305f\u3081\u306e\u9ad8\u30ec\u30d9\u30ebAPI\u304c\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>Puppeteer\u306b\u3088\u3063\u3066\u4ee5\u4e0b\u306e\u3053\u3068\u304c\u53ef\u80fd\u3068\u306a\u308a\u307e\u3059:<\/p>\n<ul>\n<li>\u30da\u30fc\u30b8\u306e\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3084PDF\u306e\u751f\u6210<\/li>\n<li>SPA\u3092\u30af\u30ed\u30fc\u30eb\u3057\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u524d\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u751f\u6210(\u4f8b\u3048\u3070\"SSR\")<\/li>\n<li>Web\u30b5\u30a4\u30c8\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0<\/li>\n<li>form\u306e\u6295\u7a3f\u3084UI\u30c6\u30b9\u30c8\u3001\u30ad\u30fc\u30dc\u30fc\u30c9\u5165\u529b\u306e\u81ea\u52d5\u5316<\/li>\n<li>\u6700\u65b0\u306e\u81ea\u52d5\u30c6\u30b9\u30c8\u958b\u767a\u767a\u7528\u306e\u69cb\u7bc9<\/li>\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u554f\u984c\u3092\u5206\u6790\u3059\u308b\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u30c8\u30ec\u30fc\u30b9\u306e\u30ad\u30e3\u30d7\u30c1\u30e3<\/li>\n<\/ul>\n<p>\u4ee5\u4e0b\u5b9f\u969b\u306b\u4f7f\u3044\u65b9\u3092\u898b\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h2>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n<p>\u5b9f\u884c\u306b\u306fNode v7.10\u4ee5\u964d\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<p>Puppeteer\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u306b\u306f\u30bf\u30fc\u30df\u30ca\u30eb\u3067\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre>\nyarn add puppeteer\n# or \"npm i puppeteer\"\n<\/pre>\n<p>\u306a\u304aPuppeteer\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u969b\u3001\u6700\u65b0\u7248\u306eChromium\u3082\u540c\u6642\u306b\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3055\u308c\u308b\u306e\u3067Mac\u3067\u306f71MB\u3001Linux\u3067\u306f90MB\u3001Windows\u3067\u306f110MB\u307b\u3069\u306e\u7a7a\u304d\u5bb9\u91cf\u304c\u5fc5\u8981\u3068\u306e\u3053\u3068\u3002<\/p>\n<h2>Web\u30da\u30fc\u30b8\u306e\u753b\u50cf\u3092\u53d6\u5f97<\/h2>\n<p>\u516c\u5f0f\u30b5\u30a4\u30c8\u3067\u306f<a href=\"https:\/\/example.com\/\">https:\/\/example.com<\/a>\u306e\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u53d6\u5f97\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0\u304c\u63b2\u8f09\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre><code class=\"javascript\">const puppeteer = require('puppeteer');\n\n(async () => {\n\n  const browser = await puppeteer.launch();\n  const page = await browser.newPage();\n  await page.goto('https:\/\/example.com');\n  await page.screenshot({path: 'example.png'});\n\n  browser.close();\n})();\n<\/code><\/pre>\n<p>\u7d30\u90e8\u306e\u610f\u5473\u306f\u3068\u3082\u304b\u304f\u3001\u30d6\u30e9\u30a6\u30b6\u3092\u8d77\u52d5\u3057\u3001\u65b0\u898f\u30da\u30fc\u30b8\u3067\u76ee\u7684\u306e\u30b5\u30a4\u30c8\u3092\u958b\u304d\u3001\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u53d6\u5f97\u3059\u308b\u3001\u3068\u3044\u3046\u4e00\u9023\u306e\u52d5\u4f5c\u3092\u884c\u3063\u3066\u3044\u308b\u3053\u3068\u304c\u306a\u3093\u3068\u306a\u304f\u5206\u304b\u308a\u307e\u3059\u3002<\/p>\n<p>\u4e0a\u8a18\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u4f8b\u3048\u3070image.js\u3068\u3057\u3066\u4fdd\u5b58\u3057\u3001\u300cnpm image.js\u300d\u3068\u3057\u3066\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" style=\"display:block; margin-left:auto; margin-right:auto;\" src=\"https:\/\/softantenna.com\/blog\/wp-content\/uploads\/2017\/08\/Is_20170818_161758.jpg\" alt=\"S 20170818 161758\" title=\"s_20170818_161758.jpg\" border=\"0\" width=\"704\" height=\"520\" \/><\/p>\n<p>\u30ab\u30ec\u30f3\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306bexample.png\u304c\u51fa\u529b\u3055\u308c\u3066\u3044\u308c\u3070\u6210\u529f\u3067\u3059\u3002\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304f\u3068\u3001Chrome\u3067example.com\u3092\u95b2\u89a7\u3057\u305f\u3068\u304d\u3068\u307e\u3063\u305f\u304f\u540c\u3058\u8868\u793a\u306b\u306a\u3063\u3066\u3044\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<p>\u516c\u5f0f\u30b5\u30a4\u30c8\u306b\u306f\u305d\u306e\u307b\u304b\u3001PDF\u3092\u751f\u6210\u3059\u308b\u65b9\u6cd5\u3084<a href=\"https:\/\/github.com\/GoogleChrome\/puppeteer\/tree\/master\/examples\/\">\u5404\u7a2e\u30b5\u30f3\u30d7\u30eb<\/a>\u304c\u63b2\u8f09\u3055\u308c\u3066\u3044\u307e\u3059\u3002API\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3068\u5408\u308f\u305b\u3066\u95b2\u89a7\u3059\u308c\u3070\u7406\u89e3\u304c\u6df1\u307e\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>Puppeteer\u306fChrome\u3060\u3051\u3092\u30bf\u30fc\u30b2\u30c3\u30c8\u3068\u3057\u3066\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3042\u308b\u305f\u3081\u3001Selenium\u3084WebDriver\u3001PhantomJS\u306a\u3069\u306e\u30af\u30ed\u30b9\u30d6\u30e9\u30a6\u30b6\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u3057\u3066\u30b7\u30f3\u30d7\u30eb\u306aAPI\u304c\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b\u306e\u304c\u9b45\u529b\u3067\u3059\u3002<\/p>\n<p>Chrome\u30e1\u30a4\u30f3\u306e\u30c6\u30b9\u30c8\u74b0\u5883\u3092\u69cb\u7bc9\u3057\u3066\u3044\u308b\u65b9\u306f\u3001Puppeteer\u306e\u5229\u7528\u3092\u8003\u616e\u3057\u3066\u307f\u308b\u306e\u304c\u826f\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google\u306fChrome 59\u3067(macOS or Linux\u7248)\u3001\u30d6\u30e9\u30a6\u30b6\u3092\u30d8\u30c3\u30c9\u30ec\u30b9\u74b0\u5883\u3067\u5b9f\u884c\u3067\u304d\u308b\u300c\u30d8\u30c3\u30c9\u30ec\u30b9Chrome\u300d\u3068\u547c\u3070\u308c\u308b\u6a5f\u80fd\u3092\u5c0e\u5165\u3057\u307e\u3057\u305f\u3002 \u81ea\u52d5\u30c6\u30b9\u30c8\u74b0\u5883\u3084\u30b5\u30fc\u30d0\u30fc\u74b0\u5883\u3067\u6d3b\u7528\u3067\u304d\u308b\u958b\u767a\u8005\u5411\u3051\u306e\u6a5f\u80fd [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":52328,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[3459],"tags":[26,1624],"class_list":["post-52272","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-review","tag-chrome","tag-node"],"_links":{"self":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/52272","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/comments?post=52272"}],"version-history":[{"count":0,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/52272\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media\/52328"}],"wp:attachment":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media?parent=52272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/categories?post=52272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/tags?post=52272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}