コード例 #1
0
ファイル: NHtmlUnitUtil.cs プロジェクト: limingyao/Crawler
        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);
            }
        }
コード例 #2
0
ファイル: NHtmlUnit.cs プロジェクト: limingyao/Crawler
 public FinalHtmlPerThread(NHtmlUnit master)
 {
     this.master = master;
     this.timeOut = master.timeOut;
     this.dic = master.dic;
     DealWithUrl();
 }