/// <summary> /// 保存数据到db /// </summary> /// <param name="httpResults"></param> /// <returns></returns> public static void SaveProductCategoryToDB(List <ProductCategory> productCategoryList) { if (productCategoryList == null) { return; } if (productCategoryList.Count <= 0) { return; } DBBaseDAL <ProductCategory> productCategoryDAL = new DBBaseDAL <ProductCategory>(); foreach (var item in productCategoryList) { try { productCategoryDAL.Add(item); } catch (Exception ex) { Log.Error(ex.ToString()); } } }
/// <summary> /// 抓取数据保存到db /// </summary> /// <param name="productId"></param> /// <returns></returns> public static void CrawlerSingleProduct(string productId) { try { Console.WriteLine(productId); var httpResults = GetProductHTML(productId); var product = ParsingHTMLToProductModel(httpResults); if (product != null) { DBBaseDAL <Product> productDAL = new DBBaseDAL <Product>(); productDAL.Add(product); } } catch (Exception ex) { Log.Error("productId:" + productId + "---" + ex.ToString()); } }