Esempio n. 1
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            if (ST0 == true)
            {
                try
                {
                    ((Button)sender).Content = "加载中";
                    basefilter = new HttpBaseProtocolFilter();
                    myfilter   = new plugInFilter(basefilter);
                    webClient  = new HttpClient(myfilter);

                    Text0 = await webClient.GetStringAsync(new Uri(Uri0));

                    加载(Text0.Substring(Text0.IndexOf("<ul class=\"Ptxt block\">"), Text0.IndexOf("<div class=\"Page\">") - Text0.IndexOf("<ul class=\"Ptxt block\">")));
                    if (Text0.Contains("下一页</a></span>"))
                    {
                        ((Button)sender).IsEnabled = true;
                        Match M2 = new Regex("(?<=(" + "class=\"p2\" href=\"" + "))[.\\s\\S]*?(?=(" + "\">下一页" + "))", RegexOptions.Multiline | RegexOptions.Singleline).Match(Text0.Substring(Text0.LastIndexOf("\">下一页") - 80, 100));
                        Uri0                     = M2.Value;
                        B0.IsEnabled             = true;
                        ((Button)sender).Content = "加载更多";
                    }
                    else
                    {
                        ((Button)sender).IsEnabled = false;
                        ((Button)sender).Content   = "到底了";
                    }
                }
                catch
                {
                    ((Button)sender).Content = "加载失败";
                    new MessageDialog("网络异常,数据加载失败,请重试或实在不行请联系作者!", "错误提示").ShowAsync();
                }
            }
        }
Esempio n. 2
0
        private async void 获取主页文本()
        {
            string Text = "0";

            try
            {
                basefilter = new HttpBaseProtocolFilter();
                myfilter   = new plugInFilter(basefilter);
                webClient  = new HttpClient(myfilter);
                Text       = await webClient.GetStringAsync(new Uri("http://acg.gamersky.com/"));//使用过滤器获取网页数据
            }
            catch
            {
                new MessageDialog("网络异常,数据加载失败,请重试或实在不行请联系作者!", "错误提示").ShowAsync();
            }
            try
            {
                if (Text.Length > 100)
                {
                    首页头条(Text.Substring(Text.IndexOf("<ul class=\"Bimg\">"), Text.IndexOf("<ul class=\"Simg\">") - Text.IndexOf("<ul class=\"Bimg\">")));
                    首页次条(Text.Substring(Text.IndexOf("<div class=\"Mid1pic\">"), Text.IndexOf("</div><!--Mid1 end-->") - Text.IndexOf("<div class=\"Mid1pic\">")));
                    今日推荐(Text.Substring(Text.IndexOf("<ul class=\"Ptxt block\">"), Text.IndexOf("<div class=\"Home-More\">") - Text.IndexOf("<ul class=\"Ptxt block\">")));
                    动漫美图(Text.Substring(Text.IndexOf("<ul class=\"DMBZ\">\r\n"), Text.IndexOf("<!--Mid6_L end-->") - Text.IndexOf("<ul class=\"DMBZ\">\r\n")));
                    Cosplay(Text.Substring(Text.IndexOf("<ul class=\"Cospaly\">"), Text.IndexOf("<!--Mid6_R end-->") - Text.IndexOf("<ul class=\"Cospaly\">")));
                    //写真(Text.Substring(Text.IndexOf("<div class=\"Mid4 R\">"), Text.IndexOf("<!--Mid_4 end-->") - Text.IndexOf("<div class=\"Mid4 R\">")));
                    //周边(Text.Substring(Text.IndexOf("<ul class=\"ZB\">"), Text.IndexOf("<ul class=\"YY\">") - Text.IndexOf("<ul class=\"ZB\">")));
                    //_动漫音乐(Text.Substring(Text.IndexOf("<ul class=\"YY\">"), Text.IndexOf("<ul class=\"RMBQ\">") - Text.IndexOf("<ul class=\"YY\">")));
                    //拆分字符串交给对应的方法解析加载
                }
            }
            catch (Exception e)
            {
                new MessageDialog("遇到致命错误,请联系作者" + e.Message, "错误提示").ShowAsync();
            }
        }
Esempio n. 3
0
        private async void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ST0 == false)
            {
                try
                {
                    basefilter = new HttpBaseProtocolFilter();
                    myfilter   = new plugInFilter(basefilter);
                    webClient  = new HttpClient(myfilter);
                    Text0      = await webClient.GetStringAsync(new Uri(@"http://acg.gamersky.com/music/"));

                    加载(Text0.Substring(Text0.IndexOf("<ul class=\"Ptxt block\">"), Text0.IndexOf("<div class=\"Page\">") - Text0.IndexOf("<ul class=\"Ptxt block\">")));
                    if (Text0.Contains("下一页</a></span>"))
                    {
                        Match M2 = new Regex("(?<=(" + "class=\"p2\" href=\"" + "))[.\\s\\S]*?(?=(" + "\">下一页" + "))", RegexOptions.Multiline | RegexOptions.Singleline).Match(Text0.Substring(Text0.LastIndexOf("\">下一页") - 80, 100));
                        Uri0 = M2.Value;
                    }
                    ST0 = true;
                    //iscw = false;
                    if (B0 != null)
                    {
                        B0.Content = "加载更多";
                    }
                }
                catch
                {
                    if (B0 != null)
                    {
                        B0.Content = "加载失败";
                    }
                    new MessageDialog("网络异常,数据加载失败,请重试或实在不行请联系作者!", "错误提示").ShowAsync();
                }
            }
        }