{"id":510,"date":"2018-09-29T15:00:24","date_gmt":"2018-09-29T06:00:24","guid":{"rendered":"https:\/\/weseek.co.jp\/tech\/?p=510"},"modified":"2023-04-17T10:30:33","modified_gmt":"2023-04-17T01:30:33","slug":"puppeteer-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e5%ae%9a%e6%9c%9f%e7%9a%84%e3%82%b9%e3%82%af%e3%83%aa%e3%83%bc%e3%83%b3%e3%82%b7%e3%83%a7%e3%83%83%e3%83%88%e3%81%ae%e5%8f%96%e5%be%97%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/weseek.co.jp\/tech\/510\/","title":{"rendered":"Puppeteer\u3067\u5b9a\u671f\u7684\u306b\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>\u305f\u304b\u304c\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3001\u3055\u308c\u3069\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3002<\/p>\n<p>\u6614\u304b\u3089Web\u30da\u30fc\u30b8\u3084Web\u30b7\u30b9\u30c6\u30e0\u306a\u3069\u306e\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u624b\u8efd\u306b\u64ae\u308a\u305f\u3044\u3001\u5b9a\u671f\u7684\u30fb\u81ea\u52d5\u7684\u306b\u64ae\u308a\u305f\u3044\u3068\u3044\u3046\u30cb\u30fc\u30ba\u306f\u5b58\u5728\u3057\u3001\u53e4\u304f\u306f ImageMagick \u5229\u7528\u304c\u4e3b\u6d41\u306e\u6642\u4ee3\u304c\u3042\u308a\u3001\u3053\u30535\u5e74\u7a0b\u3067\u306f Selenium \u306e\u5229\u7528\u304c\u6d3b\u767a\u3067\u3057\u305f\u3002\u305d\u3057\u30662018\u5e74\u73fe\u5728\u6ce8\u76ee\u3092\u96c6\u3081\u3066\u3044\u308b\u306e\u304c\u3001Google \u88fd\u306e Headless Chrome API \u306e node.js \u5b9f\u88c5\u3067\u3042\u308b <a href=\"https:\/\/pptr.dev\/\">Puppeteer<\/a> \u3067\u3059\u3002<\/p>\n<p>\u65e2\u306b Selenium \u306e\u30ce\u30a6\u30cf\u30a6\u3092\u6301\u3063\u3066\u3044\u308b\u30c1\u30fc\u30e0\u306b\u3068\u3063\u3066\u306f\u3001Puppeteer \u306e\u5229\u7528\u81ea\u4f53\u304c\u5927\u304d\u306a\u30d1\u30e9\u30c0\u30a4\u30e0\u30b7\u30d5\u30c8\u306b\u306a\u308b\u308f\u3051\u3067\u306f\u306a\u3044\u306e\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u3053\u3046\u3044\u3063\u305f\u5c0f\u3055\u306a\u30bf\u30b9\u30af\u304b\u3089\u6700\u65b0\u304b\u3064\u30b9\u30de\u30fc\u30c8\u306a\u6280\u8853\u3092\u5b9f\u9a13\u3057\u53d6\u308a\u5165\u308c\u3066\u3044\u304f\u306e\u304c\u3001\u30c1\u30fc\u30e0\u5185\u306e\u30ea\u30c6\u30e9\u30b7\u30fc\u5411\u4e0a\u3084\u5b66\u7fd2\u610f\u6b32\u30a2\u30c3\u30d7\u306b\u306f\u52b9\u679c\u7684\u3067\u3059\u3002<\/p>\n<p>\u672c\u8a18\u4e8b\u3067\u306f\u3001Puppeteer \u3068 docker\u3001\u305d\u3057\u3066 Jenkins \u3092\u4f7f\u3063\u3066\u3001\u30b5\u30af\u30c3\u3068\u5b9a\u671f\u7684\u306b\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u64ae\u308b\u65b9\u6cd5\u3092\u3001\u5b9f\u969b\u306e\u73fe\u5834\u3067\u5229\u7528\u3067\u304d\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u3068\u5171\u306b\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p><!--more--><\/p>\n\n<h2>\u30b7\u30ca\u30ea\u30aa<\/h2>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u60f3\u5b9a\u3067\u52d5\u304f\u3082\u306e\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<ul>\n<li>\n<p>\u6bce\u65e51\u56de\u3001\u6307\u5b9a\u30b5\u30a4\u30c8\u306eURL\u306e\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u64ae\u308b <\/p>\n<ul>\n<li>\u305d\u306e\u30b5\u30a4\u30c8\u306b\u306f\u8a8d\u8a3c\u304c\u5fc5\u8981\u3067\u3042\u308b<\/li>\n<li>\u30d5\u30eb\u30b5\u30a4\u30ba\u306e\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u64ae\u3063\u305f\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092 Slack \u306b Post<\/p>\n<\/li>\n<li>\n<p>\u3067\u304d\u308c\u3070 Firefox \u3082\u2026<\/p>\n<\/li>\n<\/ul>\n<h3>\u30a4\u30de\u30c9\u30ad\uff01<\/h3>\n<p>\u4e00\u6614\u524d\u3067\u3042\u308c\u3070\u3001Selenium \u3092\u52d5\u304b\u3059 Java \u306e\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u3001\u305d\u308c\u3092\u52d5\u304b\u3059\u74b0\u5883\u3092\u30e1\u30f3\u30c6\u3057\u7d9a\u3051\u308b\u3068\u3044\u3046\u65b9\u6cd5\u304c\u4e3b\u6d41\u3067\u3057\u305f\u30022018\u5e74\u73fe\u5728\u306f docker \u306e\u9686\u76db\u3082\u3042\u308a\u3001\u3084\u306f\u308a\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u53d6\u5f97\u5c02\u7528\u306e\u30b3\u30f3\u30c6\u30ca\u3092\u7acb\u3061\u4e0a\u3052\u3066\u4ed5\u4e8b\u3092\u3055\u305b\u3001\u3059\u3050\u306b\u5ec3\u68c4\u3059\u308b\u3068\u3044\u3046\u3084\u308a\u65b9\u304c\u30b9\u30de\u30fc\u30c8\u3067\u3057\u3087\u3046\u3002<\/p>\n<h2>Let's Try \uff5e\u307e\u305a\u306f\u30de\u30cb\u30e5\u30a2\u30eb\u3067\uff5e<\/h2>\n<p>\u624b\u9806\u306f\u3068\u3063\u3066\u3082\u7c21\u5358\u3001docker \u5229\u7528\u53ef\u80fd\u306a\u30de\u30b7\u30f3\u304b\u3089\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u53e9\u304f\u3060\u3051\u3067\u3059\u3002<\/p>\n<pre><code class=\"language-bash\">$ docker run --rm \\\n    -e SLACK_BOT_TOKEN=xxx-xxx-xxx \\\n    -e CHANNEL=your-channel \\\n    -e TARGET_URL=https:\/\/example.com\/path\/to\/page \\\n    -e FULL_PAGE=&lt;span class=&quot;hljs-literal&quot;&gt;true&lt;\/span&gt; \\\n    -e BASIC_AUTH_USERNAME=username \\\n    -e BASIC_AUTH_PASSWORD=password \\\n    ryysud\/screenshot2slack<\/code><\/pre>\n<p>\u6ce8: Slack bot \u306f\u4e88\u3081 <a href=\"https:\/\/my.slack.com\/services\/new\/bot\">https:\/\/my.slack.com\/services\/new\/bot<\/a> \u3067\u4f5c\u6210\u3057\u3001\u30ef\u30fc\u30af\u30b9\u30da\u30fc\u30b9\u306b\u62db\u5f85\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046<\/p>\n<p>\u3053\u308c\u3060\u3051\u3067 Slack \u306b\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u304c\u6295\u7a3f\u3055\u308c\u307e\u3059\u3002\u30d5\u30a1\u30fc\u30b9\u30c8\u30d3\u30e5\u30fc\u3060\u3051\u3067\u306a\u304f\u30d5\u30eb\u30da\u30fc\u30b8\u306e\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u64ae\u308b\u305f\u3081\u3001 <code>FULL_PAGE=true<\/code> \u3092\u540c\u6642\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>Slack \u9023\u643a\u304c\u5fc5\u8981\u306a\u304f\u3001\u30ed\u30fc\u30ab\u30eb\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u53d6\u308a\u51fa\u3057\u305f\u3044\u5834\u5408\u306f <a href=\"https:\/\/hub.docker.com\/r\/yamitzky\/puppeteer-cli\/\">yamitzky\/puppeteer-cli<\/a> \u3092\u5229\u7528\u3059\u308b\u306e\u3082\u3044\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u3053\u3061\u3089\u306e\u30a4\u30e1\u30fc\u30b8\u306f CJK \u30d5\u30a9\u30f3\u30c8\u304c\u4e88\u3081\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u308f\u3051\u3067\u306f\u306a\u3044\u306e\u3067\u3001\u65e5\u672c\u8a9e\u30b5\u30a4\u30c8\u306e\u8868\u793a\u3092\u884c\u3046\u306b\u306f\u3001\u5916\u90e8 CSS, stylesheet \u306e\u6307\u5b9a\u306b\u3088\u308b web font \u306e\u5229\u7528\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<h3>Let's Try \uff5eCookie \u306b\u3088\u308b\u30ed\u30b0\u30a4\u30f3\uff5e<\/h3>\n<p>\u30d9\u30fc\u30b7\u30c3\u30af\u8a8d\u8a3c\u3060\u3051\u3067\u306f\u4e0d\u5341\u5206\u3067\u3001\u30bb\u30c3\u30b7\u30e7\u30f3\u30ed\u30b0\u30a4\u30f3\u304c\u5fc5\u8981\u306a\u5834\u5408\u306f\u3001 cookie \u306e string \u8868\u73fe\u3092\u74b0\u5883\u5909\u6570\u306b\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3067\u5bfe\u5fdc\u3067\u304d\u307e\u3059\u3002\u4ee5\u4e0b\u306f Redmine \u306b\u30ed\u30b0\u30a4\u30f3\u3067\u304d\u308b cookie \u30c7\u30fc\u30bf\u3092\u6e96\u5099\u3059\u308b\u4f8b\u3067\u3059\u3002<\/p>\n<pre><code class=\"language-bash\">    COOKIE_VALUE_REDMINE_SESSION=&#039;xxxx....&#039;\n\n    # Cookie data for login and multiline opt\n    COOKIES_TEMPLATE=&#039;\n    [\n      {\n        name: _redmine_session,\n        value: %s,\n        domain: example.com\n      },\n      {\n        name:\n        rb_bl_multiline,\n        value: multiline,\n        domain: example.com,\n        path: \/redmine\/rb\n      }\n    ]&#039;\n    COOKIES=$(printf $COOKIES_TEMPLATE $COOKIE_VALUE_REDMINE_SESSION | tr &#039;\\n&#039; &#039; &#039;)\n\n    docker run --rm \\\n      -e SLACK_BOT_TOKEN=xxx-xxx-xxx \\\n      -e CHANNEL=your-channel \\\n      -e TARGET_URL=https:\/\/example.com\/path\/to\/page \\\n      -e FULL_PAGE=true \\\n      -e COOKIES=$COOKIES \\\n      ryysud\/screenshot2slack<\/code><\/pre>\n<h2>Let's Try \uff5e\u5b9a\u671f\u5b9f\u884c\uff5e<\/h2>\n<p>\u3042\u3068\u306f\u4e0a\u8a18\u3092 Jenkins \u3067\u5b9f\u884c\u3059\u308b\u3060\u3051\u3067\u3059\u30021 job \u306b\u3064\u304d 1 TARGET_URL \u3068\u3044\u3046\u30eb\u30fc\u30eb\u306b\u3057\u3066\u304a\u304f\u3068\u308f\u304b\u308a\u3084\u3059\u3044\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p><code>SLACK_BOT_TOKEN<\/code> \u3084 <code>COOKIE_VALUE_REDMINE_SESSION<\/code> \u306a\u3069\u306e\u79d8\u533f\u60c5\u5831\u306f\u3001Credentials \u3067\u7528\u610f\u3057\u3066\u6ce8\u5165\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>\u304a\u307e\u3051: Firefox \u5b9f\u88c5<\/h2>\n<p>Google \u8b39\u88fd\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u304c\u3001Puppeteer API \u306e Firefox \u5b9f\u88c5\u3082\u516c\u958b\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/github.com\/autonome\/puppeteer-fx\">autonome\/puppeteer-fx<\/a><\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u306e\u64ae\u308a\u65b9\u306b\u306f\u69d8\u3005\u306a\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u304c\u3001Puppeteer \u306b\u306f Selenium \u306e\u3088\u3046\u306a\u7169\u96d1\u3055\u304c\u306a\u304f\u3001puppeteer-fx \u5229\u7528\u6642\u3082\u540c\u3058 API \u3067\u540c\u3058\u3088\u3046\u306b node.js \u5411\u3051\u306e\u30b3\u30fc\u30c9\u3092\u7c21\u5358\u306b\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u308b\u3001\u3068\u3044\u3046\u3068\u3053\u308d\u304c\u30e1\u30ea\u30c3\u30c8\u3068\u8a00\u3048\u307e\u3059\u3002<\/p>\n<p>\u4e00\u65b9\u3067 Puppeteer \u81ea\u4f53\u306f\u98fd\u304f\u307e\u3067\u3082 Chrome \u306e\u305f\u3081\u306e Google \u306e\u5b9f\u88c5\u3067\u3059\u306e\u3067\u3001Edge \u3084\u305d\u306e\u4ed6\u306e\u30de\u30a4\u30ca\u30fc\u30d6\u30e9\u30a6\u30b6\u3092\u542b\u3081\u3001\u30d6\u30e9\u30a6\u30b6\u9593\u5dee\u7570\u3092\u78ba\u8a8d\u3059\u308b\u3088\u3046\u306a\u30c4\u30fc\u30eb\u3068\u3057\u3066\u306f\u5411\u304b\u306a\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u7528\u9014\u306b\u5408\u308f\u305b\u3066\u3001\u4eca\u56de\u306e\u30b3\u30fc\u30c9\u3092\u5229\u7528\u3057\u3066\u3044\u305f\u3060\u3051\u308c\u3070\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u305f\u304b\u304c\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3001\u3055\u308c\u3069\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3002 \u6614\u304b\u3089Web\u30da\u30fc\u30b8\u3084Web\u30b7\u30b9\u30c6\u30e0\u306a\u3069\u306e\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u624b\u8efd\u306b\u64ae\u308a\u305f\u3044\u3001\u5b9a\u671f\u7684\u30fb\u81ea\u52d5\u7684\u306b\u64ae\u308a\u305f\u3044\u3068\u3044\u3046\u30cb\u30fc\u30ba\u306f\u5b58\u5728\u3057\u3001\u53e4\u304f\u306f ImageMagick \u5229\u7528\u304c\u4e3b\u6d41\u306e<\/p>\n","protected":false},"author":3,"featured_media":516,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[50,17],"tags":[],"_links":{"self":[{"href":"https:\/\/weseek.co.jp\/tech\/wp-json\/wp\/v2\/posts\/510"}],"collection":[{"href":"https:\/\/weseek.co.jp\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/weseek.co.jp\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/weseek.co.jp\/tech\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/weseek.co.jp\/tech\/wp-json\/wp\/v2\/comments?post=510"}],"version-history":[{"count":15,"href":"https:\/\/weseek.co.jp\/tech\/wp-json\/wp\/v2\/posts\/510\/revisions"}],"predecessor-version":[{"id":4103,"href":"https:\/\/weseek.co.jp\/tech\/wp-json\/wp\/v2\/posts\/510\/revisions\/4103"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/weseek.co.jp\/tech\/wp-json\/wp\/v2\/media\/516"}],"wp:attachment":[{"href":"https:\/\/weseek.co.jp\/tech\/wp-json\/wp\/v2\/media?parent=510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/weseek.co.jp\/tech\/wp-json\/wp\/v2\/categories?post=510"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/weseek.co.jp\/tech\/wp-json\/wp\/v2\/tags?post=510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}