示例#1
0
 public void copy(data_conf_t conf)
 {
     id = conf.id;
     owner = conf.owner;
     url = conf.url;
     encoding = conf.encoding;
     areas = (Hashtable)conf.areas.Clone();
     cols = conf.cols;
     source = conf.source;
 }
示例#2
0
文件: frmMain.cs 项目: pengyuwei/wd
        private void btnParam_Click(object sender, EventArgs e)
        {
            DialogResult dret;
            if (comboBox1.Text.Trim().Length == 0)
            {
                return;
            }
            frmParam param = new frmParam();
            if (!work1.data_confs.ContainsKey(comboBox1.Text))
            {
                this.data_conf = new data_conf_t();
                data_conf.areas = new Hashtable();
                this.data_conf.id = comboBox1.Text;
                this.data_conf.cols = 0;
                this.data_conf.url = "http://";
                this.data_conf.encoding = "GB2312";
                work1.data_confs.Add(data_conf.id, data_conf);
                comboBox1.Items.Add(comboBox1.Text);
            }
            this.data_conf = (data_conf_t)work1.data_confs[comboBox1.Text];
            param.data_conf = this.data_conf;
            dret = param.ShowDialog();

            if (param.delete)
            {
                work1.data_confs.Remove(comboBox1.Text);
                comboBox1.Items.Remove(comboBox1.Text);
                comboBox1.Text = "";
            }
            this.data_conf = param.data_conf;
            this.data_conf.areas = param.data_conf.areas;
            work1.data_confs[comboBox1.Text] = this.data_conf;

            if (DialogResult.OK == dret)
            {
                work1.save_game();
            }
        }
示例#3
0
文件: frmMain.cs 项目: pengyuwei/wd
        private void btnGO_Click(object sender, EventArgs e)
        {
            toolStripStatusLabel1.Text = "������...";

            if (comboBox1.Text.Trim().Length == 0 || !work1.data_confs.ContainsKey(comboBox1.Text))
            {
                return;
            }
            this.data_conf = (data_conf_t)work1.data_confs[comboBox1.Text];

            if (comboBox1.Text.CompareTo("pyw") == 0) {
                this.Text = "�����ռ�������0.01 by pyw 2011";
                return;
            }

            //button4_Click(sender, e);
            button5_Click(sender, e);

            //work1.OnSourceEvent += new Class1.SourceEventHandler(work1_SourceEvent);
            //Thread workerThread = new Thread(new ThreadStart(work1.go));

            //workerThread.Start();
        }
示例#4
0
文件: frmMain.cs 项目: pengyuwei/wd
        private void Form2_Load(object sender, EventArgs e)
        {
            //CHtmlTag debug = new CHtmlTag(); int debug1 = 0; int debug2 = 0;
            //string debugstr=debug.getSourceByTag("<li><li>test</li></li>", "li", ref debug1, out debug2);
            if (DateTime.Now.Year > 2011) {
                MessageBox.Show("�������Ѿ�����");
                this.Close();
            }

            data_area_t area;

            work1 = new CWdManager();
            work1.load_game();

            /*http://s.taobao.com/search?q=iphone&keyword=&commend=all&ssid=s5-e&search_type=item&atype=&tracelog=&sourceId=tb.index
            http://s.taobao.com/search?q=iphone&commend=all&ssid=s5-e&filterFineness=2&s=40#J_FilterTabBar
            http://s.taobao.com/search?q=iphone&commend=all&filterFineness=2&ssid=s5-e&atype=b&s=80#J_FilterTabBar
             *
             *
            ��һҳ http://s.taobao.com/search?q=iphone&commend=all&atype=b&filterFineness=2&ssid=s5-e&s=120#J_FilterTabBar

            s=80��ҳ��*/

            data_conf = new data_conf_t();
            data_conf.id = "������Ϣ��ȫ��Ʒ��֤��֤����";
            data_conf.cols = 8;
            data_conf.url = "http://www.isccc.gov.cn/zsgg/08/398933.shtml";
            //data_conf.url = "http://127.0.0.1/list.htm";
            data_conf.encoding = "UTF-8";
            data_conf.areas = new Hashtable();
            // ����1:title
            area = new data_area_t("����");
            area.enable = true;
            area.from = "<head>";
            area.to = "</head>";
            area.info_path = "";
            area.regex = "(?<=<title>)[^<]*(?=</title>)";
            area.mode = AREA_MODE.REGEX;
            data_conf.areas.Add(area.id, area);
            // ����2:����
            area = new data_area_t("��������");
            //area.from = "���ߣ��й���Ϣ��ȫ��֤����";
            //area.to = "��֤��ҵչʾ";
            area.from = "<TABLE style=\"BORDER-RIGHT:";
            area.to = "</table>";
            area.regex = "(?<=<(tr).*>).*(?=<\\/\\1>)";
            area.mode = AREA_MODE.ITERATOR;
            area.info_path = "";
            area.iter_tag = "tr";
            data_conf.areas.Add(area.id, area);
            work1.data_confs.Add(data_conf.id, data_conf);

            data_conf = new data_conf_t("weibo.com");
            data_conf.cols = 0;
            data_conf.url = "http://weibo.com";
            data_conf.encoding = "UTF-8";
            data_conf.areas = new Hashtable();
            work1.data_confs.Add(data_conf.id, data_conf);

            data_conf = new data_conf_t("weibo_��㿴��.com");
            data_conf.cols = 0;
            data_conf.url = "http://127.0.0.1/weibo_suibiankankan.htm";
            data_conf.encoding = "UTF-8";
            data_conf.areas = new Hashtable();
            // ����1:title
            area = new data_area_t("title");
            area.enable = true;
            area.from = "<head>";
            area.to = "</head>";
            area.info_path = "";
            area.regex = "(?<=<title>)[^<]*(?=</title>)";
            area.mode = AREA_MODE.REGEX;
            data_conf.areas.Add(area.id, area);
            // ����2
            area = new data_area_t("��㿴���˺��б�");
            area.enable = true;
            area.from = "<ul class=\"MIB_feed\">";
            area.to = "<div class=\"feed_bt\">";
            area.info_path = "li";
            area.regex = "(?<=<a href=\")\\S+(?=\" title=\")";
            area.mode = AREA_MODE.REGEX;
            data_conf.areas.Add(area.id, area);
            work1.data_confs.Add(data_conf.id, data_conf);

            data_conf = new data_conf_t("taobao.com(iphone)");
            data_conf.cols = 0;
            data_conf.url = "http://127.0.0.1/iphone.htm";
            data_conf.url = "http://s.taobao.com/search?q=iphone&keyword=&commend=all&ssid=s5-e&search_type=item&atype=&tracelog=&sourceId=tb.index";
            data_conf.encoding = "GB2312";
            data_conf.areas = new Hashtable();
            // ����1:title
            area = new data_area_t("title");
            area.enable = true;
            area.from = "<head>";
            area.to = "</head>";
            area.info_path = "";
            area.regex = "(?<=<title>)[^<]*(?=</title>)";
            area.mode = AREA_MODE.REGEX;
            data_conf.areas.Add(area.id, area);
            // ����2
            area = new data_area_t("��Ʒ�б�");
            area.enable = true;
            area.from = "<!-- mall -->";
            area.to = "</form>";
            area.info_path = "";
            area.regex = ".*";
            area.iter_tag = "li";
            area.mode = AREA_MODE.ITERATOR;
            data_conf.areas.Add(area.id, area);
            work1.data_confs.Add(data_conf.id, data_conf);

            comboBox1.Items.Clear();
            foreach (DictionaryEntry item in work1.data_confs)
            {
                data_conf_t conf = (data_conf_t)item.Value;
                comboBox1.Items.Add(conf.id);
            }
            comboBox1.SelectedIndex = 0;
        }
示例#5
0
文件: frmMain.cs 项目: pengyuwei/wd
        private void button4_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text.Trim().Length == 0)
            {
                return;
            }
            if (!work1.data_confs.ContainsKey(comboBox1.Text))
            {
                return;
            }
            this.data_conf = (data_conf_t)work1.data_confs[comboBox1.Text];

            string url = data_conf.url;
            CWdManager test1 = new CWdManager();

            Bitmap thumbnail;// = test1.GenerateScreenshot(url, 1024, 768);
            // Generate thumbnail of a webpage at the webpage's full size (height and width)
            thumbnail = test1.GenerateScreenshot(url);

            // Display Thumbnail in PictureBox control
            pictureBox1.Image = thumbnail;
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
        }
示例#6
0
        public string getData(string url, data_conf_t conf, out string[] items)
        {
            string result = "";
            string ret = "";
            string htmlsource = getContent(url, conf.encoding);
            int from = 0;
            int to = 0;
            items = null;

            foreach (DictionaryEntry item in conf.areas)
            {
                data_area_t area = (data_area_t)item.Value;
                from = htmlsource.IndexOf(area.from,StringComparison.OrdinalIgnoreCase);
                to = htmlsource.IndexOf(area.to, from >= 0 ? from : 0, StringComparison.OrdinalIgnoreCase);

                if (from < 0 || (to < 0 && from < 0) || (to != -1 && to <= from))
                {
                    Console.WriteLine(area.id + "�����Ϲ���");
                    items = null;
                    continue;
                }
                if (to < 0)
                {
                    to = htmlsource.Length;
                }

                from += area.from.Length;

                string content = htmlsource.Substring(from, to - from);

                CHtmlTag tag = new CHtmlTag();
                int startindex = 0; int len = 0;
                //tag.getSourceByTag(content, "script", ref startindex, out len);
                //content = tag.getSourceWithoutScript(content);
                //TODO:parse html
                ret = content.Replace("\t", "");
                ret = ret.Replace("\r", "");
                ret = ret.Replace("\n", "");

                result += area.id;
                result += ":\r\n";
                if (area.mode == AREA_MODE.ITERATOR)
                {
                    result += tag.getIterInfo(ret, area);
                }
                else
                {
                    result += tag.getInfo(ret, area);
                }
                result += "\r\n\r\n";

                items = ret.Split(new char[1] { '\0' }, StringSplitOptions.RemoveEmptyEntries);
            }

            return result;
        }