public void CollectCateAction(int pageIndex) { //http://www.xiami.com/music/category/page/2?spm=a1z1s.3061713.6856357.145.an13sc // string fileXmlPath = TestFolderPath + "1\\"+pageIndex + ".txt"; //string html = File.ReadAllText(fileXmlPath, Encoding.UTF8); Thread.Sleep(6000); string html = HttpHelper.Open(string.Format(CollectTemplateXml.CollectCateAttr_url, pageIndex), "UTF-8"); string path = TestFolderPath + "CollectCatePage\\" + pageIndex + ".txt"; WriteFile(path, html, FileType.CollectCate); string main = CommonHelper.GetMatchRegexFull(CollectTemplateXml.CollectCate_Main, html); List <string> ListUnit = CommonHelper.GetMatchRegexList(CollectTemplateXml.CollectCate_Unit, main); foreach (string unit in ListUnit) { CollectCate collectCate = new CollectCate(); string keyId = CommonHelper.GetMatchRegex(CollectTemplateXml.CollectCate_KeyId, unit); collectCate.KeyId = int.Parse(keyId); //string url = CommonHelper.GetMatchRegex(CollectTemplateXml.CollectCate_Url, unit); string title = CommonHelper.GetMatchRegex(CollectTemplateXml.CollectCate_Title, unit); collectCate.CateName = title; collctService.InsertCollectCate(collectCate); LayerCollectAction(collectCate.KeyId, 1); } }
public int InsertCollectCate(CollectCate collectCate) { int result = 0; try { SqlParameter[] parms = new SqlParameter[] { new SqlParameter("keyId", collectCate.KeyId), new SqlParameter("lId", collectCate.LId), new SqlParameter("cateName", collectCate.CateName), new SqlParameter("pageIndex", collectCate.PageIndex), }; result = HelperSQL.ExecNonQuery("usp_XMSpiderCollect_Insert_CollectCate", parms); } catch (Exception ex) { LogBLL.Error("InsertCollectCate", ex); } return(result); }