Esempio n. 1
0
        private void startBtn_Click(object sender, EventArgs e)
        {
            //开始整体爬取
            if (needDeepGet.Checked && needdeepget_input.Text != "")
            {
                RegexNodeFilter NextNodeFilter   = new RegexNodeFilter("href", needdeepget_input.Text);
                SpiderManager   imgspiderManager = new SpiderManager(NextNodeFilter, "href");
                SpiderManagerController.getInstance().inputNextManager(imgspiderManager);
            }
            //打开一个新窗口
            InfoOutputForm form = new InfoOutputForm();

            this.Hide();
            form.Show();
        }
Esempio n. 2
0
        /// <summary>
        /// 当添加添加时添加一个提取规则
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addFilterBtn_click(object sender, EventArgs e)
        {
            if (htmlContent == null || htmlContent == "")
            {
                return;
            }

            SpiderManagerController managerController = SpiderManagerController.getInstance();

            if (filter_href.Checked && filter_href_input.Text != "")
            {
                RegexNodeFilter imgeNodeFilter   = new RegexNodeFilter("href", filter_href_input.Text);
                SpiderManager   imgspiderManager = new SpiderManager(imgeNodeFilter, "href");
                managerController.inputManager(imgspiderManager);
                //为了展示
                Dictionary <string, string> tmp = new Dictionary <string, string>();
                tmp.Add("href", filter_href_input.Text + "...");
                addItemIntoListView(tmp, "href");
            }

            Dictionary <String, String> rules = null;

            if (filter_id.Checked && filter_id_input.Text != "")
            {
                if (rules == null)
                {
                    rules = new Dictionary <string, string>();
                }
                rules.Add("id", filter_id_input.Text);
            }
            if (filter_class.Checked && filter_class_input.Text != "")
            {
                if (rules == null)
                {
                    rules = new Dictionary <string, string>();
                }
                rules.Add("class", filter_class_input.Text);
            }
            if (filter_name.Checked && filter_name_input.Text != "")
            {
                if (rules == null)
                {
                    rules = new Dictionary <string, string>();
                }
                rules.Add("name", filter_name_input.Text);
            }
            if (rules == null)
            {
                return;
            }
            String needInfo = null;

            if (result_text.Checked)
            {
                needInfo = "text";
            }
            else
            {
                needInfo = "href";
            }
            //开始配置爬虫
            SpiderNodeFilter spiderNodeFilter = new SpiderNodeFilter(rules);
            SpiderManager    spiderManager    = new SpiderManager(spiderNodeFilter, needInfo);

            managerController.inputManager(spiderManager);
            addItemIntoListView(rules, needInfo);
        }