//读出商品属性 private void GetProductProperties() { if (string.IsNullOrEmpty(productPage)) { auctionLog.Log("警告:传递的商品页源代码字符串为空"); return; } PropertyType tempPropertyType; string tempPropertyContent; MatchCollection tempMatches; MatchCollection matches = Regex.Matches(productPage, "<ul\\s+data-property\\s*=\\s*\"(?<name>.*?)\".*?class\\s*=\\s*\"tb-clearfix\\s+J_TSaleProp.*?\".*?<\\s*/\\s*ul\\s*>", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (matches.Count > 0) { auctionLog.Log("通知:在商品页面中发现了属性列表"); foreach (Match match in matches) { tempPropertyType = new PropertyType(); tempPropertyType.PropertyList = new ArrayList(); tempPropertyType.Name = match.Groups["name"].ToString(); tempPropertyContent = match.ToString(); tempMatches = Regex.Matches(tempPropertyContent, "<li\\s+data-value\\s*=\\s*\"(?<value>.*?)\".*?>.*?<span\\s*>\\s*(?<title>.*?)\\s*<\\s*/\\s*span\\s*>.*?<\\s*/\\s*li\\s*>", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); foreach (Match match1 in tempMatches) { TitleValuePair tvp = new TitleValuePair(); tvp.Title = match1.Groups["title"].ToString(); tvp.Value = match1.Groups["value"].ToString(); tempPropertyType.PropertyList.Add(tvp); } pts.Add(tempPropertyType); } } }
//读出商品属性 private void GetProductProperties() { if (string.IsNullOrEmpty(productPage)) { auctionLog.Log("警告:传递的商品页源代码字符串为空"); return; } PropertyType tempPropertyType; string tempPropertyContent; MatchCollection tempMatches; MatchCollection matches = Regex.Matches(productPage, "<ul\\s+data-property\\s*=\\s*\"(?<name>.*?)\".*?class\\s*=\\s*\"tb-clearfix\\s+J_TSaleProp.*?\".*?<\\s*/\\s*ul\\s*>", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (matches.Count > 0) { auctionLog.Log("通知:在商品页面中发现了属性列表"); foreach (Match match in matches) { tempPropertyType = new PropertyType(); tempPropertyType.PropertyList = new ArrayList(); tempPropertyType.Name = match.Groups["name"].ToString(); tempPropertyContent = match.ToString(); tempMatches = Regex.Matches(tempPropertyContent, "<li\\s+data-value\\s*=\\s*\"(?<value>.*?)\".*?>.*?<span\\s*>\\s*(?<title>.*?)\\s*<\\s*/\\s*span\\s*>.*?<\\s*/\\s*li\\s*>", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); foreach (Match match1 in tempMatches) { TitleValuePair tvp = new TitleValuePair(); tvp.Title = match1.Groups["title"].ToString(); tvp.Value = match1.Groups["value"].ToString(); tempPropertyType.PropertyList.Add(tvp); } pts.Add(tempPropertyType); } } }