Exemple #1
0
        public static int GetHtmlfeixi(string url, string title, Caiji cj, ArrayList keyword)
        {
            int    count = 0;
            string sql   = string.Empty;
            string Html  = GetHtml(url.Trim());

            try
            {
                Html = Html.ToString().Replace("\"", "").Replace("'", "");

                string xinxi = Html.Substring(Html.IndexOf(cj.configstart.Trim()));
                xinxi = xinxi.Remove(xinxi.IndexOf(cj.configend.Trim())).Trim();                                   //信息 //Response.Write( xinxi);

                string Introduce = Html.Substring(Html.IndexOf(cj.textstart.Trim()) + cj.textstart.Trim().Length); //全文内容
                Introduce = Introduce.Remove(Introduce.IndexOf(cj.textend.Trim())).Trim();                         //内容
                //关键词过滤
                bool   bkeyword = false;
                string keys     = "";
                //////取消关健过滤
                //////foreach (object k1 in keyword)
                //////{
                //////    if (Introduce.Contains(k1.ToString()) || title.Contains(k1.ToString()))
                //////    {
                //////        bkeyword = true;
                //////        keys = k1.ToString();
                //////        break;

                //////    }
                //////}
                //////if (bkeyword)
                //////
                {
                    youxiao++;
                    //string sql = @"INSERT INTO [dbo].[zhengce]
                    //               ([mingcheng]           ,[wenhao]           ,[faburiqi]           ,[fawendanwen]
                    //               ,[cengji]           ,[buwensheng]           ,[gongcheng]           ,[lingyu]
                    //               ,[yiju]           ,[mubiao]           ,[youxiaoqi]           ,[hangye]
                    //               ,[chanpin]            ,[zhengceqw]           ,[zcywdizhi]         ,[state]           ,[createdate]
                    //                          ,[userid])
                    //         VALUES
                    //               ('" + Common.strFilter(mingcheng.Text) + "','" + Common.strFilter(wenhao.Text) + "','" + Common.strFilter(faburiqi.Text) + "','" + Common.strFilter(fawendanwen.Text) + "','" +
                    //                     Common.strFilter(cengji.SelectedValue) + "','" + Common.strFilter(buwensheng.Text) + "','" + Common.strFilter(gongcheng.Text) + "','" + Common.strFilter(lingyu.Text) + "','" +
                    //                     Common.strFilter(yiju.Text) + "','" + Common.strFilter(mubiao.Text) + "','" + Common.strFilter(youxiaoqi.Text) + "','" + Common.strFilter(hangye.SelectedValue) + "','" +
                    //                     Common.strFilter(chanpin.Text) + "','" + Common.strFilter(content.Text) + "','" + Common.strFilter(zcywdizhi.Text) + "',1,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                    //                     + "','" + Session["userid"] + "')";

                    string wenhao   = chuli(xinxi, cj.fwhaostart, cj.fwhaoend, cj.fwhaostart.Length);
                    string faburiqi = chuli(xinxi, cj.cwdatestart, cj.cwdateend, cj.cwdatestart.Length);
                    faburiqi = shijiancl(faburiqi, faburiqi.Length);
                    string fawendanwen = chuli(xinxi, cj.fwjigoustart, cj.fwjigouend, cj.fwjigoustart.Length);
                    string youxiaoqi   = chuli(xinxi, cj.fbriqistart, cj.fbriqiend, cj.fbriqistart.Length);
                    youxiaoqi = shijiancl(youxiaoqi, youxiaoqi.Length);
                    string sqlc   = "select * from zhengce where mingcheng='" + Common.strFilter(title) + "' and wenhao='" + Common.strFilter(wenhao) + "' ";
                    int    icount = DBZheng.getSelectRowsCount(sqlc);
                    if (icount == 0)//过滤重复数据
                    {
                        sql = @"INSERT INTO [dbo].[zhengce]
                                       ([mingcheng]          ,[wenhao]           ,[faburiqi]           ,[fawendanwen],[youxiaoqi]
                                        ,[zhengceqw]           ,[zcywdizhi]         ,[state]           ,[createdate]
                                                  ,[userid],[caiji],[keys],[buwensheng],[url])
                                 VALUES
                                       ('" + Common.strFilter(title) + "','" + Common.strFilter(wenhao) + "','" + Common.strFilter(faburiqi) + "','" + Common.strFilter(fawendanwen) + "','" + Common.strFilter(youxiaoqi)
                              + "','" + Common.strFilter(Introduce) + "','" + Common.strFilter(url) + "',1,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                              + "','888',1,'" + Common.strFilter(keys) + "','" + Common.strFilter(cj.cityid.ToString()) + "','" + Common.strFilter(cj.url.ToString()) + "')";
                        count = DBZheng.getRowsCount(sql);
                    }
                    else
                    {
                        icount++;
                        chongfu++;
                    }
                }
            }
            catch { return(0); }
            if (count > 0)
            {
                return(1);
            }
            else
            {
                //数据插入错误处理
                string sql1 = "INSERT INTO[dbo].[Log]([tablename],[op],[sql],[update])VALUES('zhengce','INSERT','" + sql + "','" + DateTime.Now + "')";
                DBZheng.getRowsCount(sql1);
                return(0);
            }
        }