|
@@ -0,0 +1,870 @@
|
|
|
+
|
|
|
+<!DOCTYPE HTML>
|
|
|
+<html lang="" >
|
|
|
+ <head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
|
|
+ <title>nodejs+phantomjs+nodemailer · 代码收集</title>
|
|
|
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
|
+ <meta name="description" content="">
|
|
|
+ <meta name="generator" content="GitBook 3.1.1">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <link rel="stylesheet" href="../gitbook/style.css">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <meta name="HandheldFriendly" content="true"/>
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
|
|
+ <meta name="apple-mobile-web-app-capable" content="yes">
|
|
|
+ <meta name="apple-mobile-web-app-status-bar-style" content="black">
|
|
|
+ <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
|
|
+ <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <link rel="next" href="npm/0.html" />
|
|
|
+
|
|
|
+
|
|
|
+ <link rel="prev" href="0.html" />
|
|
|
+
|
|
|
+
|
|
|
+ </head>
|
|
|
+ <body>
|
|
|
+
|
|
|
+<div class="gb-page-wrapper">
|
|
|
+ <header class="gb-page-header">
|
|
|
+ <div class="container">
|
|
|
+
|
|
|
+
|
|
|
+<div id="book-search-input" role="search">
|
|
|
+ <input type="text" placeholder="Type to search" />
|
|
|
+</div>
|
|
|
+
|
|
|
+
|
|
|
+ <a href=".." class="logo">
|
|
|
+ <img src="../gitbook/images/logo/128.png">
|
|
|
+ <h1>代码收集</h1>
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+<a href="https://github.com/seamong/myBlogs/blob/doc/node/01_nodejs_phantomjs_nodemailer.md" target="_blank" class="btn btn-link pull-right hidden-xs">
|
|
|
+ <i class="octicon octicon-mark-github"></i> 在GitHub编辑本页
|
|
|
+</a>
|
|
|
+<a href="../faq.md" class="btn btn-link pull-right hidden-xs">
|
|
|
+ F.A.Q
|
|
|
+</a>
|
|
|
+<a href="https://github.com/seamong/myBlogs/README.md" target="_blank" class="btn btn-link pull-right hidden-xs">
|
|
|
+ 当前版本0.0.1
|
|
|
+</a>
|
|
|
+
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </header>
|
|
|
+
|
|
|
+ <div class="gb-page-body">
|
|
|
+ <div class="gb-page-inner">
|
|
|
+ <div class="container">
|
|
|
+ <div class="row">
|
|
|
+ <div class="col-md-3">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <div class="panel panel-default">
|
|
|
+
|
|
|
+ <div class="panel-heading">
|
|
|
+ <h3 class="panel-title">介绍</h3>
|
|
|
+ </div>
|
|
|
+
|
|
|
+
|
|
|
+ <div class="list-group">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="../" class="list-group-item ">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 关于本文档
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="panel panel-default">
|
|
|
+
|
|
|
+ <div class="panel-heading">
|
|
|
+ <h3 class="panel-title">JavaScript</h3>
|
|
|
+ </div>
|
|
|
+
|
|
|
+
|
|
|
+ <div class="list-group">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="../JavaScript/principle/" class="list-group-item ">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <i class="octicon octicon-chevron-right"></i>
|
|
|
+
|
|
|
+
|
|
|
+ 原理解析
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="../JavaScript/cases/" class="list-group-item ">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <i class="octicon octicon-chevron-right"></i>
|
|
|
+
|
|
|
+
|
|
|
+ 案例解析
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="panel panel-default">
|
|
|
+
|
|
|
+ <div class="panel-heading">
|
|
|
+ <h3 class="panel-title">angular</h3>
|
|
|
+ </div>
|
|
|
+
|
|
|
+
|
|
|
+ <div class="list-group">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="../angular/study_notes/" class="list-group-item ">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <i class="octicon octicon-chevron-right"></i>
|
|
|
+
|
|
|
+
|
|
|
+ Study notes
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="../angular/ng.html" class="list-group-item ">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ ng
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="panel panel-default">
|
|
|
+
|
|
|
+ <div class="panel-heading">
|
|
|
+ <h3 class="panel-title">css</h3>
|
|
|
+ </div>
|
|
|
+
|
|
|
+
|
|
|
+ <div class="list-group">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="../css/principle/" class="list-group-item ">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 原理解析
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="../css/cases/" class="list-group-item ">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <i class="octicon octicon-chevron-right"></i>
|
|
|
+
|
|
|
+
|
|
|
+ 案例收集
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="panel panel-default">
|
|
|
+
|
|
|
+ <div class="panel-heading">
|
|
|
+ <h3 class="panel-title">vue</h3>
|
|
|
+ </div>
|
|
|
+
|
|
|
+
|
|
|
+ <div class="list-group">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="../vue/components/" class="list-group-item ">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <i class="octicon octicon-chevron-right"></i>
|
|
|
+
|
|
|
+
|
|
|
+ components
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="../vue/router/" class="list-group-item ">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <i class="octicon octicon-chevron-right"></i>
|
|
|
+
|
|
|
+
|
|
|
+ router
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="../vue/vuex/" class="list-group-item ">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ VUE
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="panel panel-default">
|
|
|
+
|
|
|
+ <div class="panel-heading">
|
|
|
+ <h3 class="panel-title">ubuntu</h3>
|
|
|
+ </div>
|
|
|
+
|
|
|
+
|
|
|
+ <div class="list-group">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="../ubuntu/serves/" class="list-group-item ">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <i class="octicon octicon-chevron-right"></i>
|
|
|
+
|
|
|
+
|
|
|
+ 服务器生存指南
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="../ubuntu/instruction.html" class="list-group-item ">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 常用指令
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="../ubuntu/software/" class="list-group-item ">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 常用软件安装
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="panel panel-default">
|
|
|
+
|
|
|
+ <div class="panel-heading">
|
|
|
+ <h3 class="panel-title">GIT</h3>
|
|
|
+ </div>
|
|
|
+
|
|
|
+
|
|
|
+ <div class="list-group">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="../git/git.html" class="list-group-item ">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ git 命令
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="../git/push.html" class="list-group-item ">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ git~push
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="../git/faq.html" class="list-group-item ">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ git~F.A.Q
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="panel panel-default">
|
|
|
+
|
|
|
+ <div class="panel-heading">
|
|
|
+ <h3 class="panel-title">NODE&NPM</h3>
|
|
|
+ </div>
|
|
|
+
|
|
|
+
|
|
|
+ <div class="list-group">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="0.html" class="list-group-item ">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <i class="octicon octicon-chevron-down"></i>
|
|
|
+
|
|
|
+
|
|
|
+ node
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="01_nodejs_phantomjs_nodemailer.html" class="list-group-item active">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <i class="octicon octicon-chevron-down" style="opacity: 0"></i>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ nodejs+phantomjs+nodemailer
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="npm/0.html" class="list-group-item ">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ npm
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="panel panel-default">
|
|
|
+
|
|
|
+
|
|
|
+ <div class="list-group">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="../other/faq.html" class="list-group-item ">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ FAQ
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <a href="../other/examples.html" class="list-group-item ">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Examples
|
|
|
+
|
|
|
+
|
|
|
+ </a>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ </div>
|
|
|
+ <div class="col-md-9">
|
|
|
+
|
|
|
+<div id="book-search-results">
|
|
|
+ <div class="search-noresults">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <div class="gb-markdown book-page-inner">
|
|
|
+ <h3 id="功能">功能</h3>
|
|
|
+<p>每天定时截图,并把截到的图片自动通过邮件发送。</p>
|
|
|
+<h3 id="说明">说明</h3>
|
|
|
+<p>代码注释已经非常详细,就不多做说明,需要的朋友自己查看代码即可,主文件Mail.js,截图文件capturePart1.js,capturePart2.js,capturePart3.js,这里只展示了capturePart1.js其他两个类似。值得注意的是有登录权限的网站一定要设置Cookie,需要截取高质量图片的话截取时间一定设置长一些。</p>
|
|
|
+<h3 id="mailjs">Mail.js</h3>
|
|
|
+<pre><code> * 定时发送邮件功能说明:
|
|
|
+ * node.js必备安装模块:node_modules-->phantomjs,nodemailer,node-schedule,moment
|
|
|
+ * 涉及JS文件:route-->mail.js,public-->js-->capturePart1.js,capturePart2.js,capturePart3.js
|
|
|
+ * 截图保存地址:public-->images-->mainPage.jpeg(1600*4200)
|
|
|
+ * 截图url:http://www.***********.com
|
|
|
+ * 程序主要思路:
|
|
|
+ * (1)phantomjs截图-->参照http://phantomjs.org/
|
|
|
+ * (2)nodemailer发送邮件-->参照https://www.npmjs.com/package/nodemailer
|
|
|
+ * (3)node-schedule定时-->参照https://www.npmjs.com/package/node-schedule
|
|
|
+ * 注意:
|
|
|
+ * 改变发件服务器请修改SMTP
|
|
|
+ * 改变收件人请修改变量receiver
|
|
|
+ * 改变邮件内容请修改变量html
|
|
|
+ * 改变邮件附加图片和附件请修改attachments
|
|
|
+ * 改变截图功能请修改public-->js-->server.js
|
|
|
+ * 改变定时功能请修改变量rule
|
|
|
+ * ------Sweety
|
|
|
+//组件引入开始
|
|
|
+var schedule = require("node-schedule");
|
|
|
+var path = require('path');
|
|
|
+var childProcess = require('child_process');
|
|
|
+var phantomjs = require('phantomjs');
|
|
|
+var nodemailer = require("nodemailer");
|
|
|
+var moment = require("moment");
|
|
|
+//组件引入结束
|
|
|
+/*--------------------------------------------------------------------------------------------------------------------------------------------*/
|
|
|
+//变量定义开始
|
|
|
+var today; //今天开始时间
|
|
|
+var binPath = phantomjs.path; //获取phantomjs.exe路径
|
|
|
+var jsPath = process.cwd()+"/public/js/"; //获取server.js所在目录
|
|
|
+var childArgs;
|
|
|
+//capturePart3();
|
|
|
+//capturePart1();
|
|
|
+//变量定义结束
|
|
|
+/*--------------------------------------------------------------------------------------------------------------------------------------------*/
|
|
|
+//主程序开始
|
|
|
+var rule = new schedule.RecurrenceRule(); //schedule定时器
|
|
|
+rule.hour = 11;
|
|
|
+rule.minute = 0;
|
|
|
+rule.second = 0; //定时器规则设定(每天11点触发事件)
|
|
|
+var j = schedule.scheduleJob(rule, function(){
|
|
|
+ var now = moment();
|
|
|
+ today = now.clone().add(-1, 'days').format('YYYY-MM-DD');
|
|
|
+ capturePart1(); //触发截图事件(邮件发送功能包含在截图事件里边)
|
|
|
+});
|
|
|
+//主程序结束
|
|
|
+/*---------------------------------------------------------------------------------------------------------------------------------------------*/
|
|
|
+//phantomjs截图开始(第一张)
|
|
|
+function capturePart1(){
|
|
|
+ childArgs = [
|
|
|
+ path.join(jsPath, 'serverPart1.js'), //server.js
|
|
|
+ ' https://www.hao123.com ' //要截图的url
|
|
|
+ ];
|
|
|
+ childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
|
|
|
+ if(err)
|
|
|
+ {
|
|
|
+ console.log(err); //打印错误信息
|
|
|
+ }else{
|
|
|
+ console.log("Captured Part1 Successful !!"); //打印正确信息
|
|
|
+ capturePart2();
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+//phantomjs截图结束(第一张)
|
|
|
+//phantomjs截图开始(第二张)
|
|
|
+function capturePart2(){
|
|
|
+ childArgs = [
|
|
|
+ path.join(jsPath, 'serverPart2.js'), //server.js路径
|
|
|
+ 'https://www.hao123.com ' //要截图的url
|
|
|
+ ];
|
|
|
+ childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
|
|
|
+ if(err)
|
|
|
+ {
|
|
|
+ console.log(err); //打印错误信息
|
|
|
+ }else{
|
|
|
+ console.log("Captured Part2 Successful !!"); //打印正确信息
|
|
|
+ capturePart3();
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+//phantomjs截图结束(第二张)
|
|
|
+//phantomjs截图开始(第三张)
|
|
|
+function capturePart3(){
|
|
|
+ childArgs = [
|
|
|
+ path.join(jsPath, 'serverPart3.js'), //server.js路径
|
|
|
+ ' https://www.hao123.com ' //要截图的url
|
|
|
+ ];
|
|
|
+ childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
|
|
|
+ if(err)
|
|
|
+ {
|
|
|
+ console.log(err); //打印错误信息
|
|
|
+ }else{
|
|
|
+ console.log("Captured Part3 Successful !!"); //打印正确信息
|
|
|
+ sent(); // 触发发送邮件事件
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+//phantomjs截图结束(第三张)
|
|
|
+/*-------------------------------------------------------------------------------------------------------------------------------------------------*/
|
|
|
+//nodemailer发送邮件开始
|
|
|
+function sent(){
|
|
|
+ var imgPart1 = fs.readFileSync(process.cwd()+"/public/images/mainPagePart1.jpeg"); //图片来源
|
|
|
+ var imgPart2 = fs.readFileSync(process.cwd()+"/public/images/mainPagePart2.jpeg"); //图片来源
|
|
|
+ var imgPart3 = fs.readFileSync(process.cwd()+"/public/images/mainPagePart3.jpeg"); //图片来源
|
|
|
+ var smtpTransport = nodemailer.createTransport("SMTP",{ //邮件SMTP设定(发送邮箱服务器必须开启SMTP)
|
|
|
+ host: "smtp.xxxxx.com", // 主机
|
|
|
+ secureConnection: false, // 不使用 SSL
|
|
|
+ port: 587, // SMTP 端口
|
|
|
+ auth: {
|
|
|
+ user: "xxxxx@xxxx.com", //用户名
|
|
|
+ pass: "xxxxxx" //密码
|
|
|
+ }
|
|
|
+ });
|
|
|
+ var html = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' +
|
|
|
+ 'XX好:</br>'+
|
|
|
+ '&nbsp;&nbsp;下面为【XXXX】日报汇报('+today+')的内容,请参考</br>' +
|
|
|
+ '&nbsp;&nbsp;(日报详细信息请点击<a href="#" onclick="changeData();">此处登陆</a>查看)'+
|
|
|
+ '</br>' +
|
|
|
+ '<img src="cid:img1" id="img1">'+
|
|
|
+ '<img src="cid:img2" id="img2">'+
|
|
|
+ '<img src="cid:img3" id="img3">';//邮件内容(html代码),img唯一指定地址对应cid(见mailOptions设定)
|
|
|
+ var receiver = "xxx@xxx.com";//收件人列表
|
|
|
+ var cc = "xxxx@xxxx.com,xxx@xxx.com,xxx@xxxx.com"; //抄送人列表
|
|
|
+ var bcc = "xxx@xxxx.com,xxx@xxxx.com"; //密抄送人列表
|
|
|
+ var mailOptions = { //邮件内容选项设定
|
|
|
+ from: "<xxx@xxxx.com>", //发件地址
|
|
|
+ //to: "xxx@xxxx.com",
|
|
|
+ to: receiver, //收件人
|
|
|
+ cc:cc, //抄送人
|
|
|
+ bcc:bcc, //密抄送人
|
|
|
+ subject:"【XXXX】日报汇报("+today+")", //邮件主题
|
|
|
+ text: "【XXXX】日报汇报("+today+")", // plaintext body
|
|
|
+ html:html, //html内容
|
|
|
+ attachments: [
|
|
|
+ {
|
|
|
+ filename: 'mainPagePart1.jpeg', //图片名称
|
|
|
+ contents: imgPart1, //图片来源
|
|
|
+ cid: 'img1' //插入图片标识
|
|
|
+ },{
|
|
|
+ filename: 'mainPagePart2.jpeg', //图片名称
|
|
|
+ contents: imgPart2, //图片来源
|
|
|
+ cid: 'img2' //插入图片标识
|
|
|
+ },{
|
|
|
+ filename: 'mainPagePart3.jpeg', //图片名称
|
|
|
+ contents: imgPart3, //图片来源
|
|
|
+ cid: 'img3' //插入图片标识
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ };
|
|
|
+ smtpTransport.sendMail(mailOptions, function(error, response){//发送邮件
|
|
|
+ if(error){
|
|
|
+ console.log(error); //打印错误信息
|
|
|
+ }else{
|
|
|
+ console.log("Sent Successful !!"); //打印正确信息
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+//nodemailer发送邮件结束
|
|
|
+function changeData(){
|
|
|
+}
|
|
|
+/*---------------------------------------------------------------------------------------------------------------------------------------------*/
|
|
|
+</code></pre><h3 id="capturepart1js">capturePart1.js</h3>
|
|
|
+<pre><code>//phantomjs截图
|
|
|
+var page = require('webpage').create(),
|
|
|
+ system = require('system'),
|
|
|
+ address;
|
|
|
+page.viewportSize = { width:1920, height: 1080};
|
|
|
+page.clipRect = { top: 200, left: 210, width: 1680, height: 1530 };
|
|
|
+page.customHeaders={"Cookie":"koa:sess=e*******=;koa:sess.sig=pjadZtLAVtiO6-Haw1vnZZWrRm8"};
|
|
|
+if (system.args.length === 1) {
|
|
|
+ phantom.exit(1);
|
|
|
+} else {
|
|
|
+ address = system.args[1];
|
|
|
+ page.open(address, function (status) {
|
|
|
+ });
|
|
|
+}
|
|
|
+setTimeout(function() {
|
|
|
+ console.log("");
|
|
|
+ console.log("### STEP 5: Close page and shutdown (with a delay)");
|
|
|
+ page.render('./public/images/mainPagePart1.jpeg', {format: 'jpeg', quality: '100'});
|
|
|
+ page.close();
|
|
|
+ setTimeout(function(){
|
|
|
+ phantom.exit();
|
|
|
+ }, 3000);
|
|
|
+}, 19000);
|
|
|
+</code></pre>
|
|
|
+ </div>
|
|
|
+
|
|
|
+<hr>
|
|
|
+<div class="btn-group btn-group-justified">
|
|
|
+
|
|
|
+ <a class="btn" href="0.html"><b>上一页:</b> node</a>
|
|
|
+
|
|
|
+
|
|
|
+ <a class="btn" href="npm/0.html"><b>下一页:</b> npm</a>
|
|
|
+
|
|
|
+</div>
|
|
|
+
|
|
|
+
|
|
|
+ </div>
|
|
|
+ <div class="search-results">
|
|
|
+ <div class="has-results">
|
|
|
+
|
|
|
+ <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
|
|
+ <ul class="search-results-list"></ul>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ <div class="no-results">
|
|
|
+
|
|
|
+ <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <footer class="gb-page-footer">
|
|
|
+ <div class="container">
|
|
|
+ <ul class="menu">
|
|
|
+ <li class="pull-right">
|
|
|
+ <span class="service-info">Copyright GitBook 2018</span>
|
|
|
+ </li>
|
|
|
+ <li>
|
|
|
+ <a href="#">Return to the top</a>
|
|
|
+ </li>
|
|
|
+ <li>
|
|
|
+ <a href="#">Updated May 31st 18</a>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ </footer>
|
|
|
+</div>
|
|
|
+
|
|
|
+<script src="../gitbook/gitbook.js"></script>
|
|
|
+
|
|
|
+
|
|
|
+ <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
|
|
+
|
|
|
+
|
|
|
+<script>
|
|
|
+(function() {
|
|
|
+ gitbook.page.hasChanged({"page":{"title":"nodejs+phantomjs+nodemailer","level":"8.1.1","depth":2,"next":{"title":"npm","level":"8.2","depth":1,"path":"node/npm/0.md","ref":"./node/npm/0.md","articles":[]},"previous":{"title":"node","level":"8.1","depth":1,"path":"node/0.md","ref":"./node/0.md","articles":[{"title":"nodejs+phantomjs+nodemailer","level":"8.1.1","depth":2,"path":"node/01_nodejs_phantomjs_nodemailer.md","ref":"./node/01_nodejs_phantomjs_nodemailer.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["theme-official@2.1.1","-sharing","-fontsettings","sitemap","-search","search-pro"],"root":"./docs/","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"sitemap":{"hostname":"https://blog.honghaitao.net/"},"search-pro":{"cutWordLib":"nodejieba","defineWord":["小需求","基础建设"]},"highlight":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"theme-official":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{"version":"0.0.1"},"title":"代码收集","gitbook":"3.1.1"},"file":{"path":"node/01_nodejs_phantomjs_nodemailer.md","mtime":"2018-05-31T05:32:06.910Z","type":"markdown"},"gitbook":{"version":"3.1.1","time":"2018-05-31T05:38:08.837Z"},"basePath":"..","book":{"language":""}});
|
|
|
+})();
|
|
|
+</script>
|
|
|
+
|
|
|
+
|
|
|
+ </body>
|
|
|
+</html>
|
|
|
+
|