当前位置:编程学习 > C#/ASP.NET >>

asp.net 应用phantomjs截屏实例

请朋友们指点指定,个人英文不行,看原站API看不出什么来,纠结啊。 --------------------编程问答-------------------- --------------------编程问答-------------------- 基本是这个思路走的。
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
        
        }

结果是没有生成图片。 --------------------编程问答--------------------
引用 2 楼 andtocom 的回复:
基本是这个思路走的。
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#里调用。 --------------------编程问答-------------------- 直接打开phantomjs.exe,执行--version获得版本命令都获得不了,是不是表示安装没成功?
系统: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#)下执行 --------------------编程问答-------------------- 兄弟们帮帮忙?有网页版的,可以直接联系我QQ:275480070。
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,