⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rule_manage.aspx.cs

📁 资源大小: 116.59KB 资源类型: application 自己写个采集器 采集起来更灵活
💻 CS
📖 第 1 页 / 共 3 页
字号:
                if (enddata[i].ToString().IndexOf("http://") == -1)
                {
                    c++;
                }
            }
            if (c == enddata.Count)
            {
                string mylink = this.TextBox2.Text.Trim().Substring(7);
                mylink = mylink.Substring(0, mylink.IndexOf('/'));
                for (int i = 0; i < enddata.Count; i++)
                {
                    link.Add("http://" + mylink + "/" + enddata[i].ToString());
                }
            }
            else
            {
                for (int i = 0; i < enddata.Count; i++)
                {
                    link.Add(enddata[i].ToString());
                }
            }


            if (exper.Length > 1)
            {
                if (RadioButtonList2.Items[0].Selected == true)
                {
                    regexwl = new Regex(exper[1].Trim(), RegexOptions.IgnoreCase);
                }
                if (RadioButtonList2.Items[1].Selected == true)
                {
                    regexwl = new Regex(exper[1].Trim(), RegexOptions.Singleline);
                   
                }
                if (RadioButtonList2.Items[2].Selected == true)
                {
                    regexwl = new Regex(exper[1].Trim(), RegexOptions.ExplicitCapture);
                }
                if (RadioButtonList2.Items[3].Selected == true)
                {
                    regexwl = new Regex(exper[1].Trim(), RegexOptions.Multiline);
                }
                MatchCollection matches1 = regexwl.Matches(strOutput);
                System.Collections.IEnumerator enu1 = matches1.GetEnumerator();
                while (enu1.MoveNext() && enu1.Current != null)
                {
                    Match match = (Match)(enu1.Current);
                    title.Add(match.Value);
                }

                int b = 0;
                for (int i = 0; i < title.Count; i++)
                {
                    for (int j = 0; j < title.Count; j++)
                    {
                        if (title[i].ToString() == title[j].ToString())
                        {
                            b++;
                        }

                    }
                    if (b == 2)
                    {
                        title.RemoveAt(i);
                    }
                    b = 0;

                }
            }
            else
            {
                for (int i = 0; i < enddata.Count; i++)
                {
                    title.Add("");
                }
            }

            for (int i = 0; i < link.Count; i++)
            {
                this.ListBox1.Items.Add(link[i].ToString() + " " + title[i].ToString());
            }
        }
        catch
        { }
    }





    #region 字符串充当分隔符
    /// <summary>
    /// 字符串充当分隔符,分割字符串
    /// </summary>
    /// <param name="strinput">字符串</param>
    /// <param name="sp">分割符</param>
    /// <returns></returns>
    public static string[] split(string strinput, string sp)
    {
        string tmp = "";
        int strlen = 0, splen = 0;
        int found = 0;
        string[] rt = null;//返回数组
        try
        {
            //输入判断
            if (strinput == null || sp == null || strinput.Length == 0 || sp.Length == 0) return null;
            //初始化一个数组列表(当做动态数组)
            System.Collections.ArrayList tmp3 = new ArrayList();
            strlen = strinput.Length;//获得输入字符串的长度
            splen = sp.Length;//分隔符的长度
            for (int i = 0; i < strlen; i++)
            {
                //查找分隔符
                found = strinput.IndexOf(sp, i);
                if (found >= 0)
                {
                    tmp = "";
                    //取分隔符前的字符串
                    tmp = strinput.Substring(i, found - i);
                    //添加到数组列表
                    tmp3.Add(tmp);
                    i = found + splen - 1;
                }
                else
                {
                    string tmp2 = "";
                    //取最后的字符串
                    tmp2 = strinput.Substring(i);
                    if (tmp2 != "")
                        tmp3.Add(tmp2);
                    break;
                }
            }
            //将动态数组的维数设置成实际存在的元素个数,因为数组列表是以16的倍数递增维数的
            tmp3.TrimToSize();
            //转换数组列表为字符串数组,并返回。
            rt = (string[])tmp3.ToArray(typeof(String));
            tmp3.Clear();
        }
        catch (Exception e)
        {
            //Console.WriteLine("{0}", e.Message);
            throw e;
        }
        return rt;
    }
    #endregion


    protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.TextBox12.Text = pub();
    }

    public string pub()
    {
        string[] value1 = ListBox1.SelectedItem.Text.Split(' ');
        try
        {
            ArrayList enddata = new ArrayList();

            HttpWebRequest adsdfa = (HttpWebRequest)WebRequest.Create(value1[0]);

            HttpWebResponse aaaa = (HttpWebResponse)adsdfa.GetResponse();

            Stream strmeam = aaaa.GetResponseStream();

            StreamReader srea = new StreamReader(strmeam, Encoding.GetEncoding(this.TextBox5.Text.Trim()));

            string usedataHTML = srea.ReadToEnd();

            string strOutput = usedataHTML.Substring(usedataHTML.IndexOf(this.TextBox9.Text.Trim()));
            strOutput = strOutput.Substring(0, strOutput.IndexOf(this.TextBox10.Text.Trim()));
            string a = strOutput;
            //Regex regex = new Regex(this.TextBox11.Text.Trim());
            //MatchCollection matches = regex.Matches(strOutput);
            //System.Collections.IEnumerator enu = matches.GetEnumerator();
            //while (enu.MoveNext() && enu.Current != null)
            //{
            //    Match match = (Match)(enu.Current);
            //    a = a.Remove(a.IndexOf(match.Value), match.Value.Length);
            //}
            //return a;
            //string[] guize = split(this.TextBox11.Text.Trim(), "||||");
            //string b = "";
            //if (guize != null)
            //{
            //    for (int i = 0; i < guize.Length; i++)
            //    {
            //        Regex regex = new Regex(guize[i].Trim());
            //        MatchCollection matches = regex.Matches(a);
            //        System.Collections.IEnumerator enu = matches.GetEnumerator();
            //        while (enu.MoveNext() && enu.Current != null)
            //        {
            //            Match match = (Match)(enu.Current);
            //            //       a = a.Remove(a.IndexOf(match.Value), match.Value.Length);
            //            b += match.Value;
            //        }
            //        a = b;
            //    }
            //}
            //if (b == "")
            //{
            //    b = strOutput;
            //}

            return a;
        }
        catch
        { 
        }
        return null;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (this.TextBox1.Text.Trim().IndexOf("交友") == -1)
        {
            if (this.TextBox1.Text == "")
            {
                this.Label4.Text = "请选择";
                this.Label5.Text = "";
                this.Label2.Text = "";
            }
            else if (this.TextBox1.Text == "[object]")
            {
                this.Label4.Text = "[object]不能作为名称";
                this.Label5.Text = "";
                this.Label2.Text = "";
            }
            else if (this.TextBox2.Text == "")
            {
                this.Label4.Text = "";
                this.Label2.Text = "";
                this.Label5.Text = "请填写";
            }
            else if (this.TextBox5.Text == "")
            {
                this.Label4.Text = "";
                this.Label5.Text = "";
                this.Label2.Text = "请填写";
            }
            else if (this.TextBox6.Text == "" || this.TextBox7.Text == "" || this.TextBox8.Text == "")
            {
                this.Label4.Text = "";
                this.Label5.Text = "";
                this.Label2.Text = "";
                this.Label3.Text = "";
                Response.Write("<script>alert('请填写连接规则')</script>");
                return;
            }
            else if (this.TextBox9.Text == "" || this.TextBox10.Text == "" || this.TextBox11.Text == "")
            {
                this.Label4.Text = "";
                this.Label5.Text = "";
                this.Label2.Text = "";
                this.Label3.Text = "";
                Response.Write("<script>alert('请填写文章规则')</script>");
                return;
            }  
            else if (RadioButtonList1.Text == "")
            {
                Response.Write("<script>alert('请选择采集模式')</script>");
            }
            else if (RadioButtonList2.Text == "")
            {
                Response.Write("<script>alert('请选择采集模式')</script>");
            }
            else if (this.CheckBox1.Checked)
            {
                this.Label4.Text = "";
                this.Label5.Text = "";
                this.Label2.Text = "";
                if (this.TextBox3.Text == "" || this.TextBox4.Text == "")
                {
                    this.Label3.Text = "请填写";
                }
                else
                {
                    this.Label3.Text = "";
                }
            }

            

            if (this.ListBox1.Items.Count == 0)
            {
                this.ListBox1.Items.Add("请先测试采集");
            }
            else

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -