示例#1
0
 static void Main(string[] args)
 {
     while (true)
     {
         try
         {
             Console.WriteLine("Enter quora urls (JSON array format):");
             //eg: ["https://www.quora.com/How-do-I-become-less-boring", "https://www.quora.com/What-turns-people-off-about-Quora"]
             string[] urlList = Newtonsoft.Json.JsonConvert.DeserializeObject <string[]>(Console.ReadLine());
             for (int index = 0, urlCount = urlList.Length; index < urlCount; index++)
             {
                 var phantomJS = new NReco.PhantomJS.PhantomJS();
                 phantomJS.OutputReceived += (sender, e) =>
                 {
                     Console.WriteLine("PhantomJS output: {0}", e.Data);
                 };
                 phantomJS.ErrorReceived += (sender, e) =>
                 {
                     Console.WriteLine("PhantomJS output: {0}", e.Data);
                 };
                 phantomJS.Run("quoratopdf.js", new string[] { urlList[index] });
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine("Error: " + ex.Message);
         }
     }
 }
示例#2
0
        public List <string> CaptureByNreco(string language)
        {
            lock (locker)
            {
                var tempPath = Path.Combine(Application.StartupPath + "\\temp");
                NReco.PhantomJS.PhantomJS pjs = new NReco.PhantomJS.PhantomJS();
                pjs.ToolPath         = phantompath;
                pjs.ExecutionTimeout = new TimeSpan(0, 0, 0, 60);
                string file1 = Path.Combine(tempPath, Guid.NewGuid().ToString() + ".png");
                string file2 = Path.Combine(tempPath, Guid.NewGuid().ToString() + ".png");
                string file3 = Path.Combine(tempPath, Guid.NewGuid().ToString() + ".png");
                string file4 = Path.Combine(tempPath, Guid.NewGuid().ToString() + ".png");
                string file5 = Path.Combine(tempPath, Guid.NewGuid().ToString() + ".png");
                string file6 = Path.Combine(tempPath, Guid.NewGuid().ToString() + ".png");
                string file7 = Path.Combine(tempPath, Guid.NewGuid().ToString() + ".png");

                pjs.Run(capturejs, new string[] { url, file1, file2, file3, file4, file5, file6, file7, language, KolReportBase.domain });
                return(new string[] { file1, file2, file3, file4, file5, file6, file7 }.ToList());
            }
        }
示例#3
0
 /// <summary>
 /// Save the data to a file then load from the file.
 /// There is a flaw in this in that it doesn't split out the block, connect, dns or reieve time
 /// It is all placed in the wait and recieve times.
 /// </summary>
 /// <param name="url"></param>
 public void loadFromURL(string url)
 {
     string name = MakeValidFileName(url) + ".har";
     using (System.IO.StreamWriter file = new System.IO.StreamWriter(name, false))
     {
         NReco.PhantomJS.PhantomJS test = new NReco.PhantomJS.PhantomJS();
         test.OutputReceived += (sender, e) =>
         {
             file.Write(e.Data);
         };
         string[] args = { url };
         test.Run("netsniff.js", args);
     }
     LoadFromFile(name);
 }