public void TestCanCreatebady() { IBady badyservice = new BadyService(); Bady bady = new Bady { ID = Guid.NewGuid(), Price = "330", ImageUrl = "http://img03.taobaocdn.com/bao/uploaded/i3/15334026849221246/T19gWmFgRcXXXXXXXX_!!0-item_pic.jpg", BadyId = "60225012", Badydescription = "kunbu 女包韩版 包包2013新款 女用单肩包 女手提包 女斜挎包大包", Link = "http://detail.tmall.com/item.htm?id=21431643167", Statues = 1, Platfrom = "tmall.com", Username = "******" }; Guid id = badyservice.Create(bady); Assert.AreEqual(id, bady.ID); }
public static void GetUserBadyInfo() { IBady badyservice = new BadyService(); PaginationInfo paging = new PaginationInfo(); IList <Bady> badys = badyservice.Get(null, null, null, 1, 0, null, out paging); dt = GetTableSchema2(); foreach (Bady b in badys) { if (!string.IsNullOrEmpty(b.Twitterid)) { string url = "http://www.meilishuo.com/share/" + b.Twitterid; CookieContainer cookie = new CookieContainer(); string html = HttpHelper.GetHtml(url, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0", "application/json, text/javascript, */*; q=0.01", null, null, Encoding.UTF8); HtmlAgilityPack.HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(html); var liked = 0; var comment = 0; var record = 0; HtmlNode node = doc.DocumentNode.SelectSingleNode("//span[@class='likeNum poster_like_num']"); if (node != null) { liked = int.Parse(node.InnerText); } node = doc.DocumentNode.SelectSingleNode("//span[@class='poster_forward_num']"); if (node != null) { record = int.Parse(node.InnerText); } node = doc.DocumentNode.SelectSingleNode("//em[@class='twitter_comment_num']"); if (node != null) { comment = int.Parse(node.InnerText); } UserStore model = new UserStore { ID = Guid.NewGuid(), Bady = b, Comment = comment, Username = b.Username, Createby = "admin", Createtime = DateTime.Now.ToString(), Updatetime = DateTime.Now.ToString(), Statues = 1, Updateby = "admin", Page = 0, Rank = 0, Liked = liked, Record = record, mtype = "" }; DataRow dataRow = dt.NewRow(); dataRow[0] = model.ID; dataRow[1] = model.Username; dataRow[2] = model.Bady.ID.ToString(); dataRow[3] = model.Page; dataRow[4] = DBNull.Value; dataRow[5] = model.Liked; dataRow[6] = model.Record; dataRow[7] = model.Comment; dataRow[8] = DBNull.Value; dataRow[9] = model.Rank; dataRow[10] = model.Createby; dataRow[11] = model.Createtime; dataRow[12] = model.Updateby; dataRow[13] = model.Updatetime; dataRow[14] = model.Statues; dataRow[15] = model.mtype; dt.Rows.Add(dataRow); } } IUserStore service = new UserStoreService(); service.DeleteAll(); service.Createbatch(dt, "userstore"); Console.WriteLine("完成 宝贝数据量" + dt.Rows.Count.ToString()); dt = null; }