private void btnAdd_Click(object sender, EventArgs e) { int index = 0; string key = ""; if (data_conf.areas == null) { data_conf.areas = new Hashtable(); } data_area_t area = new data_area_t(); area.enable = true; area.from = ""; area.to = ""; area.regex = ""; area.mode = AREA_MODE.REGEX; area.info_path = ""; index = data_conf.areas.Count; do { index++; key = "区域" + index.ToString(); }while(data_conf.areas.ContainsKey(key)); area.id = key; data_conf.areas.Add(area.id, area); chklArea.Items.Add(area.id, area.enable); }
public string getInfo(string content, data_area_t area) { int i = 0; string[] buf=new string[16]; string regbuf; string ret = ""; MatchCollection mc; Regex regex; string path = area.info_path; string regex_str = area.regex; // parse path buf = path.Split(new char[1] { '/' }, StringSplitOptions.RemoveEmptyEntries); for (i = 0; i < buf.Length; i++) { regbuf = string.Format("(?<=<({0}).*>).*(?=<\\/\\1>)", buf[i]); regex = new Regex(regbuf, RegexOptions.IgnoreCase | RegexOptions.Multiline); Match m = regex.Match(content); content = m.Value; } // parse regex regex = new Regex(regex_str, RegexOptions.IgnoreCase | RegexOptions.Multiline); mc = regex.Matches(content); foreach (System.Text.RegularExpressions.Match item in mc) { //Console.WriteLine(item.Value); // parse text if (AREA_MODE.TEXT == area.mode) { ret += getText(item.Value); } else { ret += item.Value; } ret += "\r\n"; } return ret; }
public string getIterInfo(string content, data_area_t area) { string ret = ""; string buf = ""; int index = 0; int len = 0; int i = 0; do { buf = getSourceByTag(content, area.iter_tag,ref index, out len); if (len > 0) { i++; ret += i.ToString() + "\r\n"; ret += getText(buf); ret += "\r\n"; } }while(index < content.Length); //Console.WriteLine(ret); return ret; }
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; }