Ejemplo n.º 1
0
        public WeiXin_Item(WeiPublicEntity entity)
        {
            InitializeComponent();


            WeiPublicEntity = entity;
        }
Ejemplo n.º 2
0
        public void GetEntityList(string htmlUri)
        {
            try
            {
                weiPublickList.Clear();
                String html = HtmlTag.GetHtmlinfo(htmlUri);


                //List<HtmlTag> tags1 = HtmlTag.FindTagByAttr(html, "div", "id", "history");
                //var match =   regex.Matches(html);
                List <HtmlTag> tags = HtmlTag.FindTagByAttr(html, "script", "type", "text/javascript");

                string content = tags[tags.Count - 1].InnerHTML;
                string pattern = "var msgList = '{";
                string tt      = content.Substring(content.IndexOf(pattern) + pattern.Length);

                string[] sArr = tt.Split(new string[] { "&quot;title&quot" }, StringSplitOptions.RemoveEmptyEntries);
                //string[] pse = tt.Split(tt, @"&quot;,&quot;digest&quot;:&quot;" , RegexOptions.IgnoreCase);

                for (int i = 0; i < sArr.Length; i++)
                {
                    sArr[i] = sArr[i].Replace("&quot", "");
                    sArr[i] = sArr[i].Replace("\\\\/", "/");


                    string[] dsc = sArr[i].Split(new string[] { ";,;" }, StringSplitOptions.RemoveEmptyEntries);

                    if (i != 0)
                    {
                        WeiPublicEntity entity = new WeiPublicEntity();

                        for (int j = 0; j < dsc.Count(); j++)
                        {
                            if (j == 0)
                            {
                                entity.Title = dsc[j].Replace(";:;", string.Empty);
                            }
                            else if (j == 1)
                            {
                                entity.Content = dsc[j].Replace("digest;:;", string.Empty).Replace("&nbsp;", string.Empty).Replace("\\\\n", string.Empty);
                            }
                            else if (j == 3)
                            {
                                string P1 = dsc[j].Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries)[1];
                                entity.SourseUrl = "http://mp.weixin.qq.com/" + P1.Replace("amp;", string.Empty);
                            }
                            else if (j == 5)
                            {
                                string P2 = dsc[j].Split(new string[] { "cover;:;" }, StringSplitOptions.RemoveEmptyEntries)[0];
                                //P2 = P2.Replace("\"\"", "\\");

                                entity.ImageUrl = P2;
                            }
                        }
                        this.Dispatcher.BeginInvoke(new Action(() =>
                        {
                            WeiXin_Item III     = new WeiXin_Item(entity);
                            III.txtTitle.Text   = entity.Title;
                            III.txtContent.Text = entity.Content;
                            III.img.Source      = new BitmapImage(new Uri(entity.ImageUrl));
                            listBox.Items.Add(III);
                        }));


                        weiPublickList.Add(entity);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }