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

📄 start_catch.aspx.cs

📁 资源大小: 116.59KB 资源类型: application 自己写个采集器 采集起来更灵活
💻 CS
📖 第 1 页 / 共 5 页
字号:
    //                }
    //                b = b.Replace("'", "\"");

    //                usereg = new Regex(@"\[attach([\S\s]*?)\[/attach\]");//|([attach([\S\s]*?)[/attach])

    //                usematch = usereg.Matches(b);

    //                useenu = usematch.GetEnumerator();

    //                while (useenu.MoveNext() && useenu.Current != null)
    //                {
    //                    Match usemymatch = (Match)(useenu.Current);
    //                    c += usemymatch.Value;
    //                    b = b.Remove(b.IndexOf(usemymatch.Value), usemymatch.Value.Length);
    //                }

    //                if (b.IndexOf("[ 本帖最后由") >= 0)
    //                {
    //                    int aa = b.IndexOf("[ 本帖最后由");
    //                    int aaa = b.IndexOf("编辑 ]") - b.IndexOf("[ 本帖最后由") + "编辑 ]".Length;
    //                    b = b.Remove(aa, aaa);
    //                }
    //                break;
    //            }
    //            return b;
    //        }
    //        catch(Exception ex)
    //        {
    //            Response.Write(ex.Message);
    //        }
    //    }
    //    if (this.Label5.Text == "天涯")
    //    {
    //        string[] value1 = ListBox1.SelectedItem.Text.Split(' ');
    //        this.TextBox2.Text = value1[value1.Length - 1];

    //        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(myds.Tables[0].Rows[0][3].ToString().Trim()));

    //            string usedataHTML = srea.ReadToEnd();

    //            string strOutput = usedataHTML.Substring(usedataHTML.IndexOf(guize2));


    //            strOutput = strOutput.Substring(0, strOutput.IndexOf(guize3));
    //            string cont = strOutput;
    //            Regex regex = new Regex("<([\\S\\s]*?)>");
    //            MatchCollection matches = regex.Matches(strOutput);
    //            System.Collections.IEnumerator enu = matches.GetEnumerator();
    //            while (enu.MoveNext() && enu.Current != null)
    //            {
    //                Match match = (Match)(enu.Current);

    //                int qqqqq = cont.IndexOf(match.Value);
    //                int wwwww = match.Value.Length;

    //                cont = cont.Remove(cont.IndexOf(match.Value), match.Value.Length);
    //            }

    //            return cont;
    //        }
    //        catch
    //        {

    //        }
    //    }
    //    return "";
    //}
    //protected void Button1_Click(object sender, EventArgs e)
    //{
    //    if (savedata.value.Count == 0)
    //    {
    //        Label6.Text = "没有采集到文章内容";
    //    }
    //    else
    //    {
    //        Response.Redirect("databasememger.aspx?res=yes");
    //    }
    //}

    //protected void Button2_Click(object sender, EventArgs e)
    //{
    //    if (this.ListBox1.Items.Count == 0)
    //    {
    //        Label6.Text = "请先采集文章列表";
    //    }
    //    else
    //    {
    //        savedata.value.Clear();
    //        forpub();
    //        Label6.Text = "文章内容采集完成";
    //        Label6.Visible = false;
    //        this.Button2.Visible = false;
    //        this.Label2.Visible = true;
    //        this.Button1.Visible = true;
    //    } 
    //}

    //public void forpub()
    //{
    //    try
    //    {
    //        if (Label5.Text == "搜狗")
    //        {
    //            ArrayList testmydata = new ArrayList();
    //            for (int i = 0; i < ListBox1.Items.Count; i++)
    //            {
    //                string[] value1 = ListBox1.Items[i].Text.Split(' ');
    //                this.TextBox2.Text = value1[value1.Length - 1];

    //                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(myds.Tables[0].Rows[0][3].ToString().Trim()));

    //                string usedataHTML = srea.ReadToEnd();

    //                string strOutput = usedataHTML.Substring(usedataHTML.IndexOf("form"));
    //                string a = "";
    //                string b = "";
    //                string c = "";
    //                Regex regex = new Regex("<table([\\S\\s]*?)</table>");
    //                MatchCollection matches = regex.Matches(strOutput);
    //                System.Collections.IEnumerator enu = matches.GetEnumerator();
    //                while (enu.MoveNext() && enu.Current != null)
    //                {
    //                    Match match = (Match)(enu.Current);
    //                    a += match.Value;
    //                    break;
    //                }

    //                if (a != "")
    //                {
    //                    int uaq = a.IndexOf(guize2) + guize2.Length;
    //                    if (uaq != -1)
    //                    {
    //                        string str = a.Substring(uaq);
    //                        Regex regex1 = new Regex("<div([\\S\\s]*?)</div>");
    //                        MatchCollection matches1 = regex1.Matches(str);
    //                        System.Collections.IEnumerator enu1 = matches1.GetEnumerator();
    //                        while (enu1.MoveNext() && enu1.Current != null)
    //                        {
    //                            Match match1 = (Match)(enu1.Current);
    //                            b += match1.Value;

    //                            Regex usereg = new Regex(@"\(([\S\s]*?)\)");

    //                            MatchCollection usematch = usereg.Matches(b);



    //                            System.Collections.IEnumerator useenu = usematch.GetEnumerator();

    //                            while (useenu.MoveNext() && useenu.Current != null)
    //                            {
    //                                Match usemymatch = (Match)(useenu.Current);
    //                                c += usemymatch.Value;
    //                                b = b.Remove(b.IndexOf(usemymatch.Value), usemymatch.Value.Length);
    //                            }

    //                            usereg = new Regex(@"<([\S\s]*?)>");//|([attach([\S\s]*?)[/attach])

    //                            usematch = usereg.Matches(b);

    //                            useenu = usematch.GetEnumerator();

    //                            while (useenu.MoveNext() && useenu.Current != null)
    //                            {
    //                                Match usemymatch = (Match)(useenu.Current);
    //                                c += usemymatch.Value;
    //                                b = b.Remove(b.IndexOf(usemymatch.Value), usemymatch.Value.Length);

    //                                if (usemymatch.Value.StartsWith("<img"))
    //                                {
    //                                    Regex usereg1 = new Regex("\"([\\S\\s]*?).gif\"");//|([attach([\S\s]*?)[/attach])

    //                                    MatchCollection usematch1 = usereg1.Matches(usemymatch.Value);

    //                                    System.Collections.IEnumerator useenu1 = usematch1.GetEnumerator();

    //                                    while (useenu1.MoveNext() && useenu1.Current != null)
    //                                    {
    //                                        Match usemymatch1 = (Match)(useenu1.Current);
    //                                        c += usemymatch1.Value;
    //                                        string img = "[img]http://bbs.sougou.com/" + usemymatch1.Value + "[/img]";
    //                                        b += img.Remove(img.IndexOf("\""), 1).Remove(img.LastIndexOf("\"") - 1, 1);
    //                                    }
    //                                }
    //                            }

    //                            b = b.Replace("'", "\"");
    //                            usereg = new Regex(@"\[attach([\S\s]*?)\[/attach\]");//|([attach([\S\s]*?)[/attach])

    //                            usematch = usereg.Matches(b);

    //                            useenu = usematch.GetEnumerator();

    //                            while (useenu.MoveNext() && useenu.Current != null)
    //                            {
    //                                Match usemymatch = (Match)(useenu.Current);
    //                                c += usemymatch.Value;
    //                                b = b.Remove(b.IndexOf(usemymatch.Value), usemymatch.Value.Length);
    //                            }

    //                            if (b.IndexOf("[ 本帖最后由") >= 0)
    //                            {
    //                                int aa = b.IndexOf("[ 本帖最后由");
    //                                int aaa = b.IndexOf("编辑 ]") - b.IndexOf("[ 本帖最后由") + "编辑 ]".Length;
    //                                b = b.Remove(aa, aaa);
    //                            }
    //                            break;
    //                        }
    //                        testmydata.Add(b);
    //                        savedata.value.Add(b);
    //                    }
    //                    else
    //                    {
    //                        savedata.value.Add("");
    //                    }
    //                }
    //                else
    //                {
    //                    savedata.value.Add("");
    //                }
    //            }
    //        }

    //        if (Label5.Text == "天涯")
    //        {
    //            for (int i = 0; i < ListBox1.Items.Count; i++)
    //            {
    //                string[] value1 = ListBox1.Items[i].Text.Split(' ');
    //                this.TextBox2.Text = value1[value1.Length - 1];
    //                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(myds.Tables[0].Rows[0][3].ToString().Trim()));

    //                string usedataHTML = srea.ReadToEnd();

    //                string strOutput = usedataHTML.Substring(usedataHTML.IndexOf(guize2));

    //                strOutput = strOutput.Substring(0, strOutput.IndexOf(guize3));
    //                string cont = strOutput;
    //                Regex regex = new Regex("<([\\S\\s]*?)>");
    //                MatchCollection matches = regex.Matches(strOutput);
    //                System.Collections.IEnumerator enu = matches.GetEnumerator();
    //                while (enu.MoveNext() && enu.Current != null)
    //                {
    //                    Match match = (Match)(enu.Current);

    //                    int qqqqq = cont.IndexOf(match.Value);
    //                    int wwwww = match.Value.Length;

    //                    cont = cont.Remove(cont.IndexOf(match.Value), match.Value.Length);
    //                }

    //                savedata.value.Add(cont);
    //            }
    //        }
    //    }
    //    catch(Exception ex)
    //    {
    //        Response.Write(ex.Message);
    //    }
    //}
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (this.TextBox3.Text == "" || this.TextBox4.Text == "" || int.Parse(this.TextBox3.Text.Trim()) < 1 || int.Parse(this.TextBox4.Text.Trim()) > int.Parse(this.Label2.Text.Trim())||int.Parse(this.TextBox4.Text.Trim())<int.Parse(this.TextBox3.Text.Trim()))
        {
            Response.Write("<script>alert('采集范围填写有误')</script>");
        }
        else
        {
            try
            {
                this.Panel2.Visible = true;
                this.Panel3.Visible = false;
                this.Panel4.Visible = false;

⌨️ 快捷键说明

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