当前位置: 首页>>代码示例>>C#>>正文


C# HtmlHelper.Download方法代码示例

本文整理汇总了C#中System.HtmlHelper.Download方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlHelper.Download方法的具体用法?C# HtmlHelper.Download怎么用?C# HtmlHelper.Download使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.HtmlHelper的用法示例。


在下文中一共展示了HtmlHelper.Download方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Test1

        public void Test1()
        {
            //string content = DownloadHelper.Download("");
            //DownloadHelper.ParseIndexPage("http://yongche.16888.com/index.html");
            //DownloadHelper download = new DownloadHelper();
            //download.DownloadFromRequest("http://yongche.16888.com/index.html");

            //string targetPath = "c:\\a.html";

            //1. write website rule
            //2. save website info or send it to MQ queue
            /*List<UrlModel> urls = new List<UrlModel>(){
                UrlManager.CreateModel("http://yongche.16888.com/mrzs/index_1_1.html","美容知识"),
                UrlManager.CreateModel("http://yongche.16888.com/yfzs/index_1_1.html","养护知识"),
                UrlManager.CreateModel("http://yongche.16888.com/gzzs/index_1_1.html","改装知识"),
                UrlManager.CreateModel("http://yongche.16888.com/cjzs/index_1_1.html","车居知识"),
                UrlManager.CreateModel("http://yongche.16888.com/cyp/index_1_1.html","汽车用品"),
                UrlManager.CreateModel("http://yongche.16888.com/bszh/index_1_1.html","保险知识"),
                UrlManager.CreateModel("http://yongche.16888.com/wxzs/index_1_1.html","维修知识")
            };

            RuleModel rule = RuleManager.CreateModel("//dt[1]//a[2]", "//div[@class='news_list']//dl",
                                                        "//dt[1]//a[@class='f_gray']", "//dt[1]//span[@class='ico_j']",
                                                        "//dd[1]//span[1]", "//dd[1]//img[1]", "//dt[1]//span[@class='f_r']");

            WebSiteModel model = WebSiteManager.CreateModel(urls, rule, "addr");*/

            WebSiteModel model = CreateTestModel();

            string result = JsonHelper.Serializer(model);
            FileHelper.WriteTo(result, "c:\\bb.data");

            //2. download from url
            //3. save result

            WebSiteModel newModel = WebSiteManager.GetSiteInfo("c:\\bb.data");
            HtmlHelper helper = new HtmlHelper();
            List<string> targetPaths = new List<string>();

            foreach (UrlModel item in newModel.DownloadUrls)
            {
                string url = item.Url;
                string localDriver = "c:\\";
                string targetPath = string.Format("{0}{1}.html", localDriver, FileHelper.GenerateFileName(url));

                helper.Download(url);
                helper.SaveTo(helper.M_Html, targetPath);

                targetPaths.Add(targetPath);
            }

            //4. pase page from local file
            WebSiteModel parseModel = WebSiteManager.GetSiteInfo("c:\\bb.data");
            YongcheHtmlHelper yongche = new YongcheHtmlHelper();
            string tempContent = System.IO.File.ReadAllText(targetPaths[0], Encoding.Default);
            List<Article> articles = yongche.ParseArticle(tempContent, parseModel);
        }
开发者ID:priceLiu,项目名称:parse,代码行数:57,代码来源:DownloadHelperTest.cs


注:本文中的System.HtmlHelper.Download方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。