public static List <string> GetTireBrandURLs(bool isFull = false) { List <string> tireUrlList = new List <string>(); List <VehicleBrand> vehicles = new List <VehicleBrand>(); using (var vehicleclient = new VehicleClient()) { var response = vehicleclient.GetAllVehicles(); if (response != null && response.Result != null) { vehicles = response.Result.ToList(); } } IEnumerable <TireInfo> TireBrandInfos = BaseDataDAL.GetTireInfo(isFull); WeeklySitemapJob.Logger.Info("有" + TireBrandInfos.Count() + "个品牌适配轮胎"); if (vehicles != null && vehicles.Any()) { foreach (var vehicle in vehicles.Where(q => q != null)) { foreach (var tiresize in hotTiresizes) { foreach (var brand in TireBrandInfos.Where(q => q != null)) { // var count = BaseDataDAL.GetTireCount(vehicle.VehicleID, tiresize); // int pagecount = count % 20 > 0 ? count / 20 + 1 : count / 20; string w = tiresize.Substring(0, tiresize.IndexOf('/')); string a = tiresize.Substring(tiresize.IndexOf('/') + 1, tiresize.IndexOf('R') - tiresize.IndexOf('/') - 1); string r = tiresize.Substring(tiresize.IndexOf('R') + 1); tireUrlList.Add(string.Format("https://item.tuhu.cn/Tires/1/au1-b{0}-a{1}-r{2}-w{3}-v{4}.html", brand.BrandID, a, r, w, vehicle.VehicleId.Replace("-", "_"))); tireUrlList.Add(string.Format("https://item.tuhu.cn/Tires/1/au1-b{0}-a{1}-r{2}-w{3}-v{4}.html#Products", brand.BrandID, a, r, w, vehicle.VehicleId.Replace("-", "_"))); tireUrlList.Add(string.Format("https://item.tuhu.cn/Tires/1/au1-b{0}-a{1}-r{2}-w{3}-v{4}-o1.html", brand.BrandID, a, r, w, vehicle.VehicleId.Replace("-", "_"))); tireUrlList.Add(string.Format("https://item.tuhu.cn/Tires/1/au1-b{0}-a{1}-r{2}-w{3}-v{4}-o3.html", brand.BrandID, a, r, w, vehicle.VehicleId.Replace("-", "_"))); tireUrlList.Add(string.Format("https://item.tuhu.cn/Tires/1/au1-b{0}-a{1}-r{2}-w{3}-v{4}-o6.html", brand.BrandID, a, r, w, vehicle.VehicleId.Replace("-", "_"))); tireUrlList.Add(string.Format("https://item.tuhu.cn/Tires/1/au1-b{0}-a{1}-r{2}-w{3}-v{4}-o1.html#Products", brand.BrandID, a, r, w, vehicle.VehicleId.Replace("-", "_"))); tireUrlList.Add(string.Format("https://item.tuhu.cn/Tires/1/au1-b{0}-a{1}-r{2}-w{3}-v{4}-o3.html#Products", brand.BrandID, a, r, w, vehicle.VehicleId.Replace("-", "_"))); tireUrlList.Add(string.Format("https://item.tuhu.cn/Tires/1/au1-b{0}-a{1}-r{2}-w{3}-v{4}-o6.html#Products", brand.BrandID, a, r, w, vehicle.VehicleId.Replace("-", "_"))); } } } } return(tireUrlList); }
public static bool InsertTireBrandURL(bool isFull = false) { List <string> tireUrlList = new List <string>(); List <VehicleBrand> vehicles = new List <VehicleBrand>(); using (var vehicleclient = new VehicleClient()) { var response = vehicleclient.GetAllVehicles(); if (response != null && response.Result != null) { vehicles = response.Result.ToList(); } } IEnumerable <TireInfo> TireBrandInfos = BaseDataDAL.GetTireInfo(isFull); if (vehicles != null && vehicles.Any()) { foreach (var vehicle in vehicles.Where(q => q != null)) { foreach (var tiresize in hotTiresizes) { foreach (var brand in TireBrandInfos.Where(q => q != null)) { // var count = BaseDataDAL.GetTireCount(vehicle.VehicleID, tiresize); // int pagecount = count % 20 > 0 ? count / 20 + 1 : count / 20; string w = tiresize.Substring(0, tiresize.IndexOf('/')); string a = tiresize.Substring(tiresize.IndexOf('/') + 1, tiresize.IndexOf('R') - tiresize.IndexOf('/') - 1); string r = tiresize.Substring(tiresize.IndexOf('R') + 1); tireUrlList.Add(string.Format("http://item.tuhu.cn/Tires/1/b{0}-a{1}-r{2}-w{3}-v{4}.html?oe=", brand.BrandID, a, r, w, vehicle.VehicleId.Replace("-", "_"))); tireUrlList.Add(string.Format("http://item.tuhu.cn/Tires/1/b{0}-a{1}-r{2}-w{3}-v{4}.html?oe=#Products", brand.BrandID, a, r, w, vehicle.VehicleId.Replace("-", "_"))); tireUrlList.Add(string.Format("http://item.tuhu.cn/Tires/1/b{0}-a{1}-r{2}-w{3}-v{4}-o1.html?oe=#Products", brand.BrandID, a, r, w, vehicle.VehicleId.Replace("-", "_"))); tireUrlList.Add(string.Format("http://item.tuhu.cn/Tires/1/b{0}-a{1}-r{2}-w{3}-v{4}-o3.html?oe=#Products", brand.BrandID, a, r, w, vehicle.VehicleId.Replace("-", "_"))); tireUrlList.Add(string.Format("http://item.tuhu.cn/Tires/1/b{0}-a{1}-r{2}-w{3}-v{4}-o6.html?oe=#Products", brand.BrandID, a, r, w, vehicle.VehicleId.Replace("-", "_"))); } // tireUrlList.Add(string.Format("http://www.tuhu.cn/spages/Battery.aspx?pid={0}&n={1}&pl={2}", vehicle.VehicleID, i, vehicle.PaiLiang)); } } } WeeklySitemapJob.Logger.Info("有" + tireUrlList.Count() + "需要导入库"); return(InsertURLToDB(tireUrlList, "TireBrandList")); }