大家看我这一段代码 StringBuilder sbXml = new StringBuilder();
                StringWriter sw = new StringWriter(sbXml);
                XmlTextWriter tw = new XmlTextWriter(sw);
                HtmlWeb htmlWeb = new HtmlWeb();
                string httpUrl = textBox2.Text;
                if (httpUrl.Substring(0, 7) != "http://")
                {
                    httpUrl = "http://" + httpUrl;
                }
                htmlWeb.LoadHtmlAsXml(httpUrl, tw);
                string HtmlStr = sbXml.ToString().Replace(" ", "");
                mode n = new mode();
                for (int i = 0; i <= 152; i++)
                {
                    Html html = new Html();
                    string htmlCode = html.GetHTML("http://feedback.ebay.com/ws/eBayISAPI.dll?ViewFeedback2&ftab=AllFeedback&userid=paragad&iid=-1&de=off&items=25&interval=0&mPg=151&page=" + i, "gb2312");
                    //得到指定页面的html代码,第一个参数为url(貌似都知道),第二个是目标网页的编码集  
                    //正则表达式  
                    Regex regexarticles = new Regex("<span class=\"mbg-nw\">(.*?)+</span>");//获取买家名称
                    Regex re = new Regex(@"(?<=\(#)\d+(?=\))");//获取编号
                    Regex Comment = new Regex(@"\<td\>(?<val>([0-9a-zA-Z\s!+_\,\.]*))\<\/td\>\<td\snowrap\=", RegexOptions.IgnoreCase | RegexOptions.Multiline);//获取评论内容
                    Regex us = new Regex("(?is)(?<=<table[^>]*?class=\"FbOuterYukon\">.*?<img[^>]*?alt=\").*?(?=\")");//获取图片alt评价信息
                    //所有匹配表达式的内容  
                    System.Text.RegularExpressions.MatchCollection marticles = regexarticles.Matches(htmlCode);
                    System.Text.RegularExpressions.MatchCollection ma = re.Matches(htmlCode);
                    System.Text.RegularExpressions.MatchCollection co = Comment.Matches(htmlCode);
                    System.Text.RegularExpressions.MatchCollection uu = us.Matches(htmlCode);
                    //遍历匹配内容 
                    int j = 0;
                    foreach (Match m in marticles)
                    {
                        j++;
                        if (m.Groups[0].Value.IndexOf("paragad") < 0)
                        {
                            n.Buyers1 = Clear.GetKeyName(m.Groups[0].Value.Replace("paragad", ""));
                        }
                        n.Number1 = Clear.GetKeyName(ma[j].Groups[0].Value);
                        n.ContentFeedback1 = Clear.GetKeyName(co[j].Groups[1].Value);
                        if (uu[j].Groups[0].Value.IndexOf("feedback rating") >= 0)
                        {
                            n.ImageUrl1 = Clear.GetKeyName(uu[j].Groups[0].Value).Replace("feedback rating", "");
                        }
                        Form1 f = new Form1();
                        f.InsertData(n);  
                    }
private void InsertData(mode m)
        {
            string sqlstr = "insert into FeedbackProfile (Buyers,Number,ContentFeedback,ImageUrl)values(@Buyers,@Number,@ContentFeedback,@ImageUrl)";
            int i = SqlHelper.ExecuteNonQuery(sqlstr, CommandType.Text, new SqlParameter[]{
             new SqlParameter("@Buyers",m.Buyers1),
             new SqlParameter("@Number",m.Number1),
             new SqlParameter("@ContentFeedback",m.ContentFeedback1),
             new SqlParameter("@ImageUrl",m.ImageUrl1)
            });
            if (i > 0)
            {
                lb_l.Visible = true;
                lb_l.Text = "数据已经保存成功,请你查阅数据库!";
            }
            else
            {
                lb_l.Visible = true;
                lb_l.Text = "数据保存失败,可能你数据已经保存了不能重复保存!";
            }
class Html
    {
        public string GetHTML(string url, string encoding)
        {
            System.Net.WebClient web = new System.Net.WebClient();
            byte[] buffer = web.DownloadData(url);
            return Encoding.GetEncoding(encoding).GetString(buffer);
        }
    }但是一执行,就出现了这种错误,这是什么原因呀???
求高手解决呀RegExC#数据库行业数据

解决方案 »

  1.   

    帮忙解决一下吧,是不是正则表达式有问题呀?我要筛选保存这个网站上面的数据http://feedback.ebay.com/ws/eBayISAPI.dll?ViewFeedback2&ftab=AllFeedback&userid=paragad&iid=-1&de=off&items=25&interval=0&mPg=151
      

  2.   

    http://feedback.ebay.com/ws/eBayISAPI.dll?ViewFeedback2&ftab=AllFeedback&userid=paragad&iid=-1&de=off&items=25&interval=0&mPg=151
    我要筛选获取到这个网站上面的这个模块下面的所有评论内容,比如:Told item was not in stock after I paid - refund room far too long. Poor seller!和very fast delivery. Thank you guys for awesome Service和Top seller, fast and top product. Thanks!和Fast postage, great item. A very good seller和Good等这些内容,正则表达是怎么写呀???求懂正则表达式的帮忙呀
      

  3.   

    Bitmap originalImage =(Bitmap)Bitmap.FromFile(originalImagePath);
                    int thumWidth = width;//缩略图的宽度        
                    int thumHeight = height; //缩略图的高度       
                    int x = 0; int y = 0;
                    int originalWidth = originalImage.Width;//原始图片的宽度       
                    int originalHeight = originalImage.Height;//原始图片的高度        
                    switch (model)
                    {
                        case "HW": //指定高宽缩放,可能变形                
                            break;
                        case "W": //指定宽度,高度按照比例缩放               
                            thumHeight = originalImage.Height * width / originalImage.Width;
                            break;
                        case "H": //指定高度,宽度按照等比例缩放                
                            thumWidth = originalImage.Width * height / originalImage.Height;
                            break;
                        case "Cut":
                            if ((double)originalImage.Width / (double)originalImage.Height > (double)thumWidth / (double)thumHeight)
                            {
                                originalHeight = originalImage.Height;
                                originalWidth = originalImage.Height * thumWidth / thumHeight; y = 0; x = (originalImage.Width - originalWidth) / 2;
                            }
                            else
                            {
                                originalWidth = originalImage.Width;
                                originalHeight = originalWidth * height / thumWidth; x = 0;
                                y = (originalImage.Height - originalHeight) / 2;
                            }
                            break;
                        default:
                            break;
                    }  //新建一个bmp图片        
                    System.Drawing.Image bitmap = new System.Drawing.Bitmap(thumWidth, thumHeight); //新建一个画板        
                    System.Drawing.Graphics graphic = System.Drawing.Graphics.FromImage(bitmap); //设置高质量查值法       
                    graphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;        //设置高质量,低速度呈现平滑程度   
                    graphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;        //清空画布并以透明背景色填充       
                    graphic.Clear(System.Drawing.Color.Transparent);        //在指定位置并且按指定大小绘制原图片的指定部分       
                    graphic.DrawImage(originalImage, new System.Drawing.Rectangle(0, 0, thumWidth, thumHeight), new System.Drawing.Rectangle(x, y, originalWidth, originalHeight),
                   System.Drawing.GraphicsUnit.Pixel);
                   originalImage.Dispose();
                   graphic.Dispose();
                   GC.Collect();
                    try
                    {
                        bitmap.Save(thumNailPath, System.Drawing.Imaging.ImageFormat.Jpeg);
                    }
                    catch (Exception ex) { throw ex; }
                    finally { originalImage.Dispose(); bitmap.Dispose(); graphic.Dispose(); GC.Collect(); }这是我写的代码,执行程序时间,过一段时间报错提示Bitmap originalImage =(Bitmap)Bitmap.FromFile(originalImagePath);这一句内存不足是咋回事呀???求高手帮忙呀