private List <ecar_list> GetList(string url) { #region//具体业务代码 List <ecar_list> list = new List <ecar_list>(); string source = HtmlHandle.HtmlCode(url); if (source != "") { int start = source.IndexOf("<!--筛选结果 开始-->"); int end = source.IndexOf("<!--筛选结果 结束-->"); string data = source.Substring(start, end - start); data = data.Replace("\n", "").Replace(" ", "").Replace("\r", ""); MatchCollection mu = BLL.Matchs(data, Rule.Ueritem); foreach (Match u in mu) { string car = BLL.One_Match(u.ToString(), Rule.listcar); MatchCollection mc = BLL.Matchs(u.ToString(), Rule.herfItem); foreach (Match m in mc) { ecar_list model = new ecar_list(); model.car = car; model.url = m.Groups[1].Value; model.title = m.Groups[2].Value; list.Add(model); } } } #endregion return(list); }
private List <ecar_list> GetList(string url, RegexList_Model RLmodel) { #region//具体业务代码 List <ecar_list> list = new List <ecar_list>(); string source = HtmlHandle.HtmlCode(url); if (source != "") { //int start = source.IndexOf("<!--筛选结果 开始-->"); //int end = source.IndexOf("<!--筛选结果 结束-->"); //string data = source.Substring(start, end - start); //data = data.Replace("\n", "").Replace(" ", "").Replace("\r", ""); string data = source.Replace("\n", "").Replace(" ", "").Replace("\r", ""); MatchCollection mu = List_BLL.Matchs(data, RegexBLL.GenerateRegex(RLmodel.listRule)); foreach (Match u in mu) { string car = List_BLL.One_Match(u.ToString(), RegexBLL.GenerateRegex(RLmodel.carRule)); MatchCollection mc = List_BLL.Matchs(u.ToString(), RegexBLL.GenerateRegex(RLmodel.userRule)); foreach (Match m in mc) { ecar_list model = new ecar_list(); model.rgid = ID; model.car = car; model.url = RegexBLL.One_Match(m.Groups[0].Value, RegexBLL.GenerateRegex(RLmodel.urlRule)); model.title = RegexBLL.One_Match(m.Groups[0].Value, RegexBLL.GenerateRegex(RLmodel.titleRule)); list.Add(model); } } } #endregion return(list); }
private string GetList(string url) { #region//具体业务代码 string showdata = ""; string source = HtmlHandle.HtmlCode(url); if (source != "") { string data = source.Replace("\n", "").Replace(" ", "").Replace("\r", ""); List <ecar_list> list = new List <ecar_list>(); MatchCollection mu = BLL.Matchs(data, RegexBLL.GenerateRegex(reg_list)); foreach (Match u in mu) { string car = BLL.One_Match(u.ToString(), RegexBLL.GenerateRegex(reg_car)); MatchCollection mc = BLL.Matchs(u.ToString(), RegexBLL.GenerateRegex(reg_user)); foreach (Match m in mc) { ecar_list model = new ecar_list(); model.car = car; model.url = RegexBLL.One_Match(m.Groups[0].Value, RegexBLL.GenerateRegex(reg_url)); model.title = RegexBLL.One_Match(m.Groups[0].Value, RegexBLL.GenerateRegex(reg_title)); list.Add(model); } } foreach (ecar_list m in list) { showdata = showdata + m.car + "\n" + m.url + "\n" + m.title + "<br>"; } } #endregion return(showdata); }
public int SavetoDb(string url) { ecar_content model = new ecar_content(); string source = HtmlHandle.HtmlCode(url); string data = source.Replace("\n", "").Replace(" ", "").Replace("\r", ""); #region//绑定数据 model.title = title.Match(data).Groups[1].Value; if (model.title == "") { model.title = "微口碑"; } model.url = url; model.type = type.Match(data).Groups[1].Value; model.car = car.Match(data).Groups[1].Value; model.malladdr = address.Match(data).Groups[1].Value; model.buydata = buydate.Match(data).Groups[1].Value; model.price = price.Match(data).Groups[1].Value; model.oil = oil.Match(data).Groups[1].Value; model.satisfied = satisfied.Match(data).Groups[1].Value; model.unsatisfied = unsatisfied.Match(data).Groups[1].Value; //具体内容 model.oil_star = oilItem.Match(data).Groups[1].Value; model.oil_sum = oilItem.Match(data).Groups[2].Value; model.operation_star = operationItem.Match(data).Groups[1].Value; model.operation = operationItem.Match(data).Groups[2].Value; model.power_star = powerItem.Match(data).Groups[1].Value; model.power = powerItem.Match(data).Groups[2].Value; model.space_star = spaceItem.Match(data).Groups[1].Value; model.space = spaceItem.Match(data).Groups[2].Value; if (model.title == "微口碑") { model.synthetical_star = syntheticalItem_wkb.Match(data).Groups[1].Value; model.synthetical = syntheticalItem_wkb.Match(data).Groups[2].Value; } else { model.synthetical_star = syntheticalItem.Match(data).Groups[1].Value; model.synthetical = syntheticalItem.Match(data).Groups[2].Value; } model.appearance_star = appearanceItem.Match(data).Groups[1].Value; model.appearance = appearanceItem.Match(data).Groups[2].Value; model.comfort_star = comfortItem.Match(data).Groups[1].Value; model.comfort = comfortItem.Match(data).Groups[2].Value; model.config_star = configItem.Match(data).Groups[1].Value; model.config = configItem.Match(data).Groups[2].Value; model.costperfor_star = costperforItem.Match(data).Groups[1].Value; model.costperfor = costperforItem.Match(data).Groups[2].Value; model.inside_star = insideItem.Match(data).Groups[1].Value; model.inside = insideItem.Match(data).Groups[2].Value; #endregion return(0);//new Ecar_koubei_Dal().Save(model);//具体存储 }
private string GetList(string url) { #region//具体业务代码 string showdata = ""; string source = HtmlHandle.HtmlCode(url); if (source != "") { string data = source.Replace("\n", "").Replace(" ", "").Replace("\r", ""); ecar_content model = new ecar_content(); #region//model赋值 model.url = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(url)); model.title = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(title)); model.car = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(car)); model.type = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(type)); model.buydata = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(buydata)); model.malladdr = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(malladdr));//购车地址 model.price = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(price)); model.oil = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(oil)); model.oil_sum = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(oil_sum)); // model.operation = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(operation)); //操控 model.costperfor = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(costperfor)); //性价比 model.config = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(config)); model.comfort = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(comfort)); //舒适度 model.space = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(space)); // model.power = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(power)); // model.appearance = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(appearance)); model.inside = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(inside)); model.synthetical = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(synthetical)); //综合 model.wsynthetical = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(wsynthetical)); //综合 model.oil_star = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(oil_star)); model.operation_star = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(operation_star)); //操控 model.costperfor_star = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(costperfor_star)); //性价比 model.config_star = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(config_star)); model.comfort_star = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(comfort_star)); //舒适度 model.space_star = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(space_star)); // model.power_star = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(power_star)); // model.appearance_star = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(appearance_star)); model.inside_star = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(inside_star)); model.synthetical_star = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(synthetical_star)); //综合 model.wsynthetical_star = RegexBLL.One_Match(data, RegexBLL.GenerateRegex(wsynthetical_star)); //综合 #endregion #region//数据展示 showdata = "链接:" + model.url + "<br/>" + "标题:" + model.title + "<br/>" + "车型:" + model.car + "<br/>" + "类型:" + model.type + "<br/>" + "购车日期:" + model.buydata + "<br/>" + "购车地址:" + model.malladdr + "<br/>" +//购车地址 "购车价格:" + model.price + "<br/>" + "油耗:" + model.oil + "<br/>" + "油耗评价:" + model.oil_sum + "<br/>" + // "油耗评分:" + model.operation + "<br/>" + //操控 "性价比评价:" + model.costperfor + "<br/>" + //性价比 "配置评价:" + model.config + "<br/>" + "舒适度评价:" + model.comfort + "<br/>" + //舒适度 "空间评价:" + model.space + "<br/>" + // "动力评价:" + model.power + "<br/>" + // "外观评价:" + model.appearance + "<br/>" + "内饰评价:" + model.inside + "<br/>" + "综合评价:" + model.synthetical + "<br/>" + //综合 "微口碑评价:" + model.wsynthetical + "<br/>" + //综合 "油耗评分:" + model.oil_star + "<br/>" + "操控评分:" + model.operation_star + "<br/>" + //操控 "性价比评分:" + model.costperfor_star + "<br/>" + //性价比 "配置评分:" + model.config_star + "<br/>" + "舒适度评分:" + model.comfort_star + "<br/>" + //舒适度 "空间评分:" + model.space_star + "<br/>" + // "动力评分:" + model.power_star + "<br/>" + // "外观评分:" + model.appearance_star + "<br/>" + "内饰评分:" + model.inside_star + "<br/>" + "综合评分:" + model.synthetical_star + "<br/>" +//综合 "微口碑评分:" + model.wsynthetical_star + "<br/>"; #endregion } #endregion return(showdata); }
private string GetList(string url) { #region//具体业务代码 string showdata = ""; string source = HtmlHandle.HtmlCode(url); if (source != "") { #region //int start = source.IndexOf("<!--筛选结果 开始-->"); //int end = source.IndexOf("<!--筛选结果 结束-->"); //string data = source.Substring(start, end - start); //data = data.Replace("\n", "").Replace(" ", "").Replace("\r", ""); #endregion string data = source.Replace("\n", "").Replace(" ", "").Replace("\r", ""); List <ecar_list> list = new List <ecar_list>(); MatchCollection mu = BLL.Matchs(data, RegexBLL.GenerateRegex(liststart + "([\\S\\s]*?)" + listend)); foreach (Match u in mu) { string car = BLL.One_Match(u.ToString(), RegexBLL.GenerateRegex(carstart + "([\\S\\s]*?)" + carend)); MatchCollection mc = BLL.Matchs(u.ToString(), RegexBLL.GenerateRegex(userstart + "([\\S\\s]*?)" + userend)); foreach (Match m in mc) { ecar_list model = new ecar_list(); model.car = car; model.url = RegexBLL.One_Match(m.Groups[0].Value, RegexBLL.GenerateRegex(urlstart + "([\\S\\s]*?)" + urlend)); model.title = RegexBLL.One_Match(m.Groups[0].Value, RegexBLL.GenerateRegex(titlestart + "([\\S\\s]*?)" + titleend)); list.Add(model); } } #region //MatchCollection mu = BLL.Matchs(data, Rule.Ueritem); //foreach (Match u in mu) //{ // string car = BLL.One_Match(u.ToString(), Rule.listcar); // MatchCollection mc = BLL.Matchs(u.ToString(), Rule.herfItem); // foreach (Match m in mc) // { // ecar_list model = new ecar_list(); // model.car = car; // model.url = m.Groups[1].Value; // model.title = m.Groups[2].Value; // list.Add(model); // } //} #endregion foreach (ecar_list m in list) { showdata = showdata + m.car + "\n" + m.url + "\n" + m.title + "<br>"; } } #endregion return(showdata); }
protected void Page_Load(object sender, EventArgs e) { if (Request["url"] != "") { url = Request["url"].Trim().ToString(); } string source = HtmlHandle.HtmlCode(url); if (source != "") { string data = source.Replace("\n", "").Replace(" ", "").Replace("\r", ""); ecar_content model = new ecar_content(); model.car = BLL.One_Match(data, Rule.car); model.title = BLL.One_Match(data, Rule.title); model.type = BLL.One_Match(data, Rule.type); model.malladdr = BLL.One_Match(data, Rule.address); model.buydata = BLL.One_Match(data, Rule.buydate); model.price = BLL.One_Match(data, Rule.price); model.oil = BLL.One_Match(data, Rule.oil); model.satisfied = BLL.One_Match(data, Rule.satisfied); model.unsatisfied = BLL.One_Match(data, Rule.unsatisfied); MatchCollection oilItem = BLL.Matchs(data, Rule.oilItem); foreach (Match m in oilItem) { model.oil_star = m.Groups[1].Value; model.oil_sum = m.Groups[2].Value; } MatchCollection operationItem = BLL.Matchs(data, Rule.operationItem); foreach (Match m in operationItem) { model.operation_star = m.Groups[1].Value; model.operation = m.Groups[2].Value; } MatchCollection costperforItem = BLL.Matchs(data, Rule.costperforItem); foreach (Match m in costperforItem) { model.costperfor_star = m.Groups[1].Value; model.costperfor = m.Groups[2].Value; } MatchCollection configItem = BLL.Matchs(data, Rule.configItem); foreach (Match m in configItem) { model.config = m.Groups[1].Value; model.config_star = m.Groups[2].Value; } MatchCollection comfortItem = BLL.Matchs(data, Rule.comfortItem); foreach (Match m in comfortItem) { model.comfort = m.Groups[1].Value; model.comfort_star = m.Groups[2].Value; } MatchCollection spaceItem = BLL.Matchs(data, Rule.spaceItem); foreach (Match m in spaceItem) { model.space_star = m.Groups[1].Value; model.space = m.Groups[2].Value; } MatchCollection powerItem = BLL.Matchs(data, Rule.powerItem); foreach (Match m in powerItem) { model.operation_star = m.Groups[1].Value; model.operation = m.Groups[2].Value; } MatchCollection appearanceItem = BLL.Matchs(data, Rule.appearanceItem); foreach (Match m in appearanceItem) { model.appearance_star = m.Groups[1].Value; model.appearance = m.Groups[2].Value; } MatchCollection insideItem = BLL.Matchs(data, Rule.insideItem); foreach (Match m in insideItem) { model.inside_star = m.Groups[1].Value; model.inside = m.Groups[2].Value; } MatchCollection syntheticalItem = BLL.Matchs(data, Rule.syntheticalItem); foreach (Match m in syntheticalItem) { model.synthetical_star = m.Groups[1].Value; model.synthetical = m.Groups[2].Value; } string showdata = model.car + "/r/n" + model.url + "/r/n" + model.title + "/r/n" + model.type + "/r/n" + model.malladdr + "/r/n" + model.buydata + model.price + "/r/n" + model.oil + "/r/n" + model.satisfied + "\n" + model.unsatisfied; Response.Write(showdata); } }
protected void Page_Load(object sender, EventArgs e) { if (Request["url"] != "") { url = Request["url"].Trim().ToString(); } if (Request["series"] != "") { series = Request["series"].Trim().ToString(); } string source = HtmlHandle.HtmlCode(url); if (source != "") { #region//数据获取 string data = source.Replace("\n", "").Replace(" ", "").Replace("\r", ""); ecar_content model = new ecar_content(); model.car = BLL.One_Match(data, Rule.car); model.title = BLL.One_Match(data, Rule.title); model.type = BLL.One_Match(data, Rule.type); model.malladdr = BLL.One_Match(data, Rule.address); model.buydata = BLL.One_Match(data, Rule.buydate); model.price = BLL.One_Match(data, Rule.price); model.oil = BLL.One_Match(data, Rule.oil); model.satisfied = BLL.One_Match(data, Rule.satisfied); model.unsatisfied = BLL.One_Match(data, Rule.unsatisfied); MatchCollection oilItem = BLL.Matchs(data, Rule.oilItem); foreach (Match m in oilItem) { model.oil_star = m.Groups[1].Value; model.oil_sum = m.Groups[2].Value; } MatchCollection operationItem = BLL.Matchs(data, Rule.operationItem); foreach (Match m in operationItem) { model.operation_star = m.Groups[1].Value; model.operation = m.Groups[2].Value; } MatchCollection costperforItem = BLL.Matchs(data, Rule.costperforItem); foreach (Match m in costperforItem) { model.costperfor_star = m.Groups[1].Value; model.costperfor = m.Groups[2].Value; } MatchCollection configItem = BLL.Matchs(data, Rule.configItem); foreach (Match m in configItem) { model.config_star = m.Groups[1].Value; model.config = m.Groups[2].Value; } MatchCollection comfortItem = BLL.Matchs(data, Rule.comfortItem); foreach (Match m in comfortItem) { model.comfort_star = m.Groups[1].Value; model.comfort = m.Groups[2].Value; } MatchCollection spaceItem = BLL.Matchs(data, Rule.spaceItem); foreach (Match m in spaceItem) { model.space_star = m.Groups[1].Value; model.space = m.Groups[2].Value; } MatchCollection powerItem = BLL.Matchs(data, Rule.powerItem); foreach (Match m in powerItem) { model.operation_star = m.Groups[1].Value; model.operation = m.Groups[2].Value; } MatchCollection appearanceItem = BLL.Matchs(data, Rule.appearanceItem); foreach (Match m in appearanceItem) { model.appearance_star = m.Groups[1].Value; model.appearance = m.Groups[2].Value; } MatchCollection insideItem = BLL.Matchs(data, Rule.insideItem); foreach (Match m in insideItem) { model.inside_star = m.Groups[1].Value; model.inside = m.Groups[2].Value; } MatchCollection syntheticalItem = BLL.Matchs(data, Rule.syntheticalItem); foreach (Match m in syntheticalItem) { model.synthetical_star = m.Groups[1].Value; model.synthetical = Regex.Replace(m.Groups[2].Value.ToString(), "<[\\S\\s]*?>", "").ToString(); } #endregion #region//绑定 lbl_car.InnerText = series + model.car + model.type; txt_title.Value = model.title; txt_buydate.Value = model.buydata; txt_buyprice.Value = model.price; txt_car_oil.Value = model.oil; txt_oil_summary.Value = model.oil_sum; txt_inside_summary.Value = model.inside; txt_drive_summary.Value = model.operation; txt_config_summary.Value = model.config; txt_comfort_summary.Value = model.comfort; txt_cost_summary.Value = model.costperfor; txt_power_summary.Value = model.power; txt_appearance_summary.Value = model.appearance; txt_space_summary.Value = model.space; txt_all_summary.Value = model.synthetical; //type = model.type;// allstar = model.synthetical_star; powerstar = model.power_star; oilstar = model.oil_star; drivestar = model.operation_star; configstar = model.config_star; coststar = model.costperfor_star; comfortstar = model.comfort_star; apperstar = model.appearance_star; spacestar = model.space_star; insidestar = model.inside_star; #endregion rep_type.DataSource = T_BLL.Get_ALL(); rep_type.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { string url = "http://car.bitauto.com/xinbaolai/koubei/"; string data = HtmlHandle.HtmlCode(url); //data=data.Replace(" ","").Replace("\r\n\r\n","\r\n").Replace("\r\n\r\n","\r\n"); int start = data.IndexOf("<!--筛选结果 开始-->"); int end = data.IndexOf("<!--筛选结果 结束-->"); string show = data.Substring(start, end - start); show = show.Replace("\n", "").Replace(" ", "").Replace("\r", ""); List <ecar_list> list = new List <ecar_list>(); string showdata = ""; //string[] sArray = show.Split( new string[]{"<divclass=\"kb-list-box\">","</div></div></div></div>"}, StringSplitOptions.RemoveEmptyEntries); string regx = "<divclass=\"titbox\"><a[\\S\\s]*?>([\\S\\s]*?)</a>"; string regq = "<divclass=\"titbox\"><ahref=\"([\\S\\s]*?)\"targe"; #region //业务代码 MatchCollection mu = Regex_BLL.Matchs(show, Rule.Ueritem); foreach (Match u in mu) { ecar_list model = new ecar_list(); model.car = Regex_BLL.One_Match(u.ToString(), Rule.listcar); MatchCollection mc = Regex_BLL.Matchs(u.ToString(), Rule.herfItem); foreach (Match m in mc) { model.url = Regex_BLL.One_Match(m.Groups[0].Value, Regex_BLL.GenerateRegex(regq)); model.title = Regex_BLL.One_Match(m.Groups[0].Value, Regex_BLL.GenerateRegex(regx)); list.Add(model); } } #endregion SavetoDb("http://car.bitauto.com/leikesasies/koubei/948884/"); #region//弃用 //MatchCollection mu = herfItem.Matches(show); //foreach (Match u in mu) //{ // ecar_list model = new ecar_list(); // model.car = listcar.Match(u.ToString()).Groups[1].Value; // MatchCollection mc = herfItem.Matches(u.ToString()); // foreach (Match m in mc) // { // model.url = m.Groups[1].Value; // model.title = m.Groups[2].Value; // list.Add(model); // } //} #endregion #region//弃用 //for (int i = 1; i < sArray.Length; i++) //{ // ecar_list model = new ecar_list(); // int titstart = sArray[i].IndexOf("<divclass=\"titbox\">"); // int titend = sArray[i].IndexOf("</div><pclass"); // if (titstart != -1) // { // model.title = sArray[i].Substring(titstart, titend - titstart); // } // int urlstart = sArray[i].IndexOf("ahref=\""); // int urlend = sArray[i].IndexOf("\"rel"); // if (urlstart != -1) // { // model.url = sArray[i].Substring(urlstart, urlend - urlstart); // } // int carstart = sArray[i].IndexOf("<h6>"); // int carend = sArray[i].IndexOf("</h6>"); // if (carstart != -1) // { // model.car = sArray[i].Substring(carstart, carend - carstart); // } // list.Add(model); //} #endregion foreach (ecar_list m in list) { showdata = showdata + m.car + "\n" + m.url + "\n" + m.title + "<br>"; } Response.Write(showdata); //string carPy = "baomax5"; //GetUrl Geturl = new demo.GetUrl(GetUrlList); //Thread UrlThread = new Thread(new ThreadStart(Geturl(carPy))); //UrlThread.Start(); //savetodb stod = new savetodb(GotoSave); //Thread StoDb = new Thread(new ThreadStart(stod(list))); //StoDb.Start(); }