Beispiel #1
0
        public void Run()
        {

            NHtmlUnit html = new NHtmlUnit();
            if (html.Run(url, dic, timeout))
            {
                htmlstring += "<title>" + html.HtmlTitle + "</title>\n";

                StringBuilder sb = new StringBuilder();
                sb.Append("<linkList>");
                foreach (String link in html.LinkList)
                {
                    sb.Append(link);
                }
                sb.Append("</linkList>");
                htmlstring += sb.ToString();

                sb = new StringBuilder();
                sb.Append("<imageList>");
                foreach (String img in html.ImageList)
                {
                    sb.Append(img);
                }
                sb.Append("</imageList>");
                htmlstring += sb.ToString();

                htmlstring += html.HtmlBody;

                success = true;
                //保存数据到文件
                StreamWriter writer = new StreamWriter(File.OpenWrite(filename));
                writer.WriteLine(htmlstring);
                writer.Close();
                Console.WriteLine("data save in " + filename);
            }
        }
Beispiel #2
0
 public FinalHtmlPerThread(NHtmlUnit master)
 {
     this.master = master;
     this.timeOut = master.timeOut;
     this.dic = master.dic;
     DealWithUrl();
 }