基本是这个思路走的。
private void GetImage(string url) { string links = url.IndexOf("http://") > -1 ? url : "http://" + url; #region 启动进程
Process p = new Process();
p.StartInfo.FileName = Environment.CurrentDirectory+"//phantomjs.exe";
p.StartInfo.WorkingDirectory = Environment.CurrentDirectory+"//pic//";
p.StartInfo.Arguments = string.Format("--ignore-ssl-errors=yes --load-plugins=yes " + Environment.CurrentDirectory + "//rasterize.js " + links + " "+url+".png");
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; if (!p.Start())
throw new Exception("无法Headless浏览器."); #endregion
}
结果是没有生成图片。
private void GetImage(string url) { string links = url.IndexOf("http://") > -1 ? url : "http://" + url; #region 启动进程
Process p = new Process();
p.StartInfo.FileName = Environment.CurrentDirectory+"//phantomjs.exe";
p.StartInfo.WorkingDirectory = Environment.CurrentDirectory+"//pic//";
p.StartInfo.Arguments = string.Format("--ignore-ssl-errors=yes --load-plugins=yes " + Environment.CurrentDirectory + "//rasterize.js " + links + " "+url+".png");
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; if (!p.Start())
throw new Exception("无法Headless浏览器."); #endregion
}
结果是没有生成图片。
这个就是执行phantomjs.exe 并得到结果。你先在command line下吧phantomjs.exe的参数搞明白,再在C#里调用。
系统:windows 2003
string links = url.IndexOf("http://") > -1 ? url : "http://" + url; #region 启动进程
Process p = new Process();
p.StartInfo.FileName = @"e:\jp\cuts\bin\phantomjs.exe";
p.StartInfo.WorkingDirectory = @"e:\jp\cuts\pic\";
p.StartInfo.Arguments = "--ignore-ssl -errors=yes --load-images=yes @e:\\jp\\cuts\\bin\\snap.js " + links + " @e:\\jp\\cuts\\pic\\1111111.png";
p.StartInfo.CreateNoWindow = false;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
if (!p.Start())
{
throw new Exception("无法Headless浏览器.");
}
#endregion什么动静也没有。在asp.net(C#)下执行