本文整理匯總了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);
}