{"id":890,"date":"2019-04-19T10:12:07","date_gmt":"2019-04-19T02:12:07","guid":{"rendered":"http:\/\/blog.5danyuan.com\/?p=890"},"modified":"2019-04-19T10:12:07","modified_gmt":"2019-04-19T02:12:07","slug":"phantomjs","status":"publish","type":"post","link":"https:\/\/blog.5danyuan.com\/?p=890","title":{"rendered":"PhantomJS"},"content":{"rendered":"\n<p>\u6700\u8fd1\u4e00\u76f4\u90fd\u5728\u7528\u4e00\u4e2a\u7f51\u4e0a\u514d\u8d39\u7684xx\u670d\u52a1\uff0c\u4f46\u662f\u5176\u8d26\u53f7\u4f1a<\/p>\n\n\n\n<p>\u6700\u8fd1\u4e00\u76f4\u90fd\u5728\u7528\u4e00\u4e2a\u7f51\u4e0a\u514d\u8d39\u7684xx\u670d\u52a1\uff0c\u4f46\u662f\u5176\u8d26\u53f7\u4f1a\u66f4\u65b0\uff0c\u6240\u4ee5\u5c31\u9700\u8981\u65f6\u4e0d\u65f6\u5730\u8bbf\u95ee\u5176\u9875\u9762\u4ee5\u83b7\u53d6\u66f4\u65b0\u7684\u8d26\u53f7\u3002\u8fd9\u4e0d\uff0c\u7a81\u7136\u5c31\u65e0\u6cd5\u8bbf\u95ee\u4e86\u3002\u6211\u7528\u6d77\u5916\u7684\u670d\u52a1\u5668\u8bbf\u95ee\u4e86\u4e0b\uff0c\u53d1\u73b0\u8fd8\u662f\u53ef\u4ee5\u8bbf\u95ee\u7684\u3002\u4f46\u662f\u8fd9\u4e2a\u7f51\u9875\u7684\u5185\u5bb9\u662f\u7528 js \u52a8\u6001\u751f\u6210\u7684\uff0c\u8fd9\u6837\u5c31\u65e0\u6cd5\u7b80\u5355\u5730\u67e5\u770b\u4e86\u3002<\/p>\n\n\n\n<p>\u6240\u4ee5\u5c31\u60f3\u6709\u6ca1\u6709\u4ec0\u4e48\u5de5\u5177\u53ef\u4ee5\u83b7\u53d6\u7f51\u9875\u7684dom\u6811\uff0c\u521a\u5f00\u59cb\u65f6\u641c\u7d22\u4e86\u4e0b\u547d\u4ee4\u884c\u7684\u6d4f\u89c8\u5668\uff0c\u540e\u6765\u53d1\u73b0\u4e0d\u80fd\u6ee1\u8db3\u8981\u6c42\uff0c\u56e0\u4e3a\u6211\u9700\u8981\u70b9\u51fb\u9875\u9762\u91cc\u7684\u4e00\u4e2a\u6309\u94ae\u4ee5\u590d\u5236\u8d26\u53f7\u4fe1\u606f\u3002\u540e\u6765\u6362\u4e86\u4e2a\u601d\u8def\uff0c\u5982\u679c\u53ef\u4ee5\u751f\u6210\u7f51\u9875\u622a\u56fe\u7684\u8bdd\uff0c\u8d77\u7801\u6211\u53ef\u4ee5\u624b\u52a8\u7684\u901a\u8fc7\u626b\u63cf\u4e8c\u7ef4\u7801\u6765\u6dfb\u52a0\u8d26\u53f7\u3002<\/p>\n\n\n\n<p>\u540e\u6765\u5728\u7f51\u4e0a\u53d1\u73b0\u4e86\u8fd9\u4e2a\u5de5\u5177\uff1aPhantomJS\uff0c\u6309\u7167\u5b98\u7f51\u8bf4\u6cd5\uff0c\u5b83\u53ef\u4ee5\u751f\u6210\u7f51\u9875\u5feb\u7167\uff0c\u8f85\u52a9\u505a\u4e00\u4e9b\u81ea\u52a8\u5316\u6d4b\u8bd5\u7684\u5de5\u4f5c\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"273\" height=\"300\" src=\"https:\/\/blog.5danyuan.com\/wp-content\/uploads\/2019\/04\/PhantomJS-273x300.png\" alt=\"\" class=\"wp-image-891\" srcset=\"https:\/\/blog.5danyuan.com\/wp-content\/uploads\/2019\/04\/PhantomJS-273x300.png 273w, https:\/\/blog.5danyuan.com\/wp-content\/uploads\/2019\/04\/PhantomJS.png 420w\" sizes=\"auto, (max-width: 273px) 100vw, 273px\" \/><\/figure><\/div>\n\n\n\n<p>\u7b80\u5355\u626b\u63cf\u4e86\u4e0b\u793a\u4f8b\u4ee3\u7801\uff0c\u5728 example \u76ee\u5f55\u4e0b\uff0c\u6070\u597d\u5c31\u6709\u4e00\u4e2a\u73b0\u6210\u7684\u4f8b\u5b50\uff08rasterize.js\uff09\uff0c\u8c03\u7528\u4e5f\u5f88\u7b80\u5355\uff0c\u4f8b\u5982 .\\phantomjs.exe ..\\examples\\rasterize.js https:\/\/www.baidu.com\/ image.png 1920px\u3002\u5bf9\u4e8e\u6700\u540e\u4e00\u4e2a\u53c2\u6570\uff0c\u9700\u8981\u591a\u8bf4\u4e00\u53e5\uff0c\u5b98\u65b9\u7684\u793a\u4f8b\u8fd0\u884c\u4f1a\u62a5\u9519\uff08ReferenceError: Strict mode forbids implicit creation of global property &#8216;pageWidth&#8217;\uff09\uff0c\u5728\u4ee3\u7801\u7684\u5f00\u59cb\u90e8\u5206\u6dfb\u52a0 pageWidth\u548cpageHeight\u5b9a\u4e49\u5373\u53ef\u3002<\/p>\n\n\n\n<p>\u6d77\u5916\u7684\u670d\u52a1\u5668\u4e48\uff0c\u81ea\u7136\u4f1a\u6709\u53e6\u5916\u4e00\u4e2a\u95ee\u9898\u5c31\u662f\u5bf9\u4e8e\u4e2d\u6587\u7684\u652f\u6301\uff0capt-get install xfonts-* \u5b8c\u4e8b\u3002<\/p>\n\n\n\n<p>\u6700\u540e\u770b\u5230\u4e86\u751f\u6210\u7684\u622a\u56fe\uff0c\u4e0a\u9762\u8bf4\u5982\u679c\u65e0\u6cd5\u8bbf\u95ee\uff0c\u5c31\u4f7f\u7528 IP \u4ee3\u66ff\u7b49\u7b49\uff0c\u4e8e\u662f\u6dfb\u52a0\u4e86\u4e00\u4e2ahost\u89e3\u6790\uff0c\u7ec8\u4e8e\u6d4f\u89c8\u5668\u53ef\u4ee5\u6b63\u5e38\u8bbf\u95ee\u4e86\u3002<\/p>\n\n\n\n<p>\u56de\u5230\u9700\u6c42\u672c\u8eab\u4e0a\u6765\uff0c\u540e\u7eed\u770b\u770b\u662f\u5426\u53ef\u4ee5\u7528PhantomJS\u4f5c\u4e3a\u76d1\u63a7\uff0c\u6bcf\u5f53\u66f4\u65b0\u4e86\u8d26\u53f7\u4fe1\u606f\u65f6\u5c31\u4e3b\u52a8\u901a\u77e5\u6211\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u4e00\u76f4\u90fd\u5728\u7528\u4e00\u4e2a\u7f51\u4e0a\u514d\u8d39\u7684xx\u670d\u52a1\uff0c\u4f46\u662f\u5176\u8d26\u53f7\u4f1a \u6700\u8fd1\u4e00\u76f4\u90fd\u5728\u7528\u4e00\u4e2a\u7f51\u4e0a\u514d\u8d39\u7684xx\u670d\u52a1\uff0c\u4f46\u662f\u5176\u8d26\u53f7\u4f1a\u66f4\u65b0\uff0c\u6240 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,308],"tags":[],"class_list":["post-890","post","type-post","status-publish","format-standard","hentry","category-a-short-word","category-308"],"_links":{"self":[{"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=\/wp\/v2\/posts\/890","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=890"}],"version-history":[{"count":0,"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=\/wp\/v2\/posts\/890\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}