Example #1
0
        private void DownloadHtmlContent3(String _content)
        {
            HtmlDoc.LoadHtml(_content);
            HtmlNode node = HtmlDoc.DocumentNode.SelectSingleNode("//head//title");

            PageTitle = (node != null ? node.InnerText : HtmlDoc.DocumentNode.InnerText).Trim();
        }
Example #2
0
        private async void VisitUrlAsync()
        {
            if (!enableRefresh)
            {
                return;
            }
            if (hasInit == false)
            {
                return;
            }

            URLHTML = await MainFrm.RunBusyWork(() =>
            {
                HttpStatusCode code;
                ConfigFile.GetConfig <DataMiningConfig>().RequestCount++;
                return(GetHtml(URL, out code));
            }, title : GlobalHelper.Get("long_visit_web"));

            if (URLHTML.Contains(GlobalHelper.Get("key_671")) &&
                MessageBox.Show(GlobalHelper.Get("key_672") + URLHTML + GlobalHelper.Get("key_673"), GlobalHelper.Get("key_99"),
                                MessageBoxButton.OK) == MessageBoxResult.OK)

            {
                return;
            }


            ControlExtended.SafeInvoke(() =>
            {
                HtmlDoc.LoadHtml(URLHTML);
                if (MainDescription.IsUIForm)
                {
                    var dock    = MainFrm as IDockableManager ?? ControlExtended.DockableManager;
                    var control = dock?.ViewDictionary.FirstOrDefault(d => d.Model == this);
                    if (control != null)
                    {
                        dynamic invoke = control.View;
                        if (IsSuperMode == false)
                        {
                            invoke.UpdateHtml(URLHTML);
                            OnPropertyChanged("HtmlDoc");
                        }
                        else
                        {
                            invoke.UpdateHtml(GlobalHelper.Get("key_674"));
                        }
                    }
                }
            },
                                       name: GlobalHelper.Get("key_675"));


            if (string.IsNullOrWhiteSpace(selectText) == false)
            {
                currentXPaths = HtmlDoc.SearchXPath(SelectText, () => IsAttribute).GetEnumerator();
                GetXPathAsync();
            }
            OnPropertyChanged("URLHTML");
        }
Example #3
0
        private async void VisitUrlAsync()
        {
            if (!enableRefresh)
            {
                return;
            }
            if (hasInit == false)
            {
                return;
            }

            URLHTML = await MainFrm.RunBusyWork(() =>
            {
                HttpStatusCode code;
                RequestManager.Instance.RequestCount++;
                return(GetHtml(URL, out code));
            });

            if (URLHTML.Contains("尝试自动重定向") &&
                MessageBox.Show("网站提示: " + URLHTML + "\n 通常原因是网站对请求合法性做了检查, 建议填写关键字对网页内容进行自动嗅探", "提示信息",
                                MessageBoxButton.OK) == MessageBoxResult.OK)

            {
                return;
            }


            ControlExtended.SafeInvoke(() =>
            {
                HtmlDoc.LoadHtml(URLHTML);
                if (MainDescription.IsUIForm)
                {
                    var dock    = MainFrm as IDockableManager ?? ControlExtended.DockableManager;
                    var control = dock?.ViewDictionary.FirstOrDefault(d => d.Model == this);
                    if (control != null)
                    {
                        dynamic invoke = control.View;
                        if (IsSuperMode == false)
                        {
                            invoke.UpdateHtml(URLHTML);
                            OnPropertyChanged("HtmlDoc");
                        }
                        else
                        {
                            invoke.UpdateHtml("超级模式下内置浏览器不展示内容,请查看左侧的文本内容");
                        }
                    }
                }
            },
                                       name: "解析html文档");


            if (string.IsNullOrWhiteSpace(selectText) == false)
            {
                currentXPaths = HtmlDoc.SearchXPath(SelectText, () => IsAttribute).GetEnumerator();
                GetXPathAsync();
            }
            OnPropertyChanged("URLHTML");
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.NavigationMode == NavigationMode.New)
            {
                Bookitem = e.Parameter as BookItem;
                bookDetailsGrid.DataContext = Bookitem;
                localTitle = MainPage.TitleTextBlock.Text = Bookitem.Title;
                var htmlPage = await HTMLParser.Instance.GetHtml(Bookitem.Interlinkage);

                if (htmlPage == null)
                {
                    await MainPage.PopMessageDialog("网络或服务器故障!");

                    return;
                }
                HtmlDoc.LoadHtml(htmlPage);
                var contentNode = HtmlDoc.GetElementbyId("content");
                var summary     = contentNode.ChildNodes[1].ChildNodes[7].ChildNodes[1].ChildNodes[3].ChildNodes[13].InnerText;
                readLinkage          = contentNode.ChildNodes[1].ChildNodes[11].ChildNodes[1].ChildNodes[1].ChildNodes[1].ChildNodes[3].ChildNodes[0].Attributes["href"].Value;
                Bookitem.Summary     = summary.Replace("&nbsp;", " ");
                Bookitem.ReadLinkage = readLinkage;
                try {
                    var localFolder = ApplicationData.Current.LocalCacheFolder;
                    var file        = await localFolder.GetFileAsync("collectedNovels.txt");

                    var collectedNovels = await FileIO.ReadTextAsync(file);

                    if (collectedNovels.Contains(Bookitem.BID))
                    {
                        CollectButton.Content = "取消收藏";
                    }
                    else
                    {
                        CollectButton.Content = "添加收藏";
                    }
                }
                catch (Exception) {
                    CollectButton.Content = "添加收藏";
                }

                summaryTextBlock.Text = Bookitem.Summary;

                htmlPage = await HTMLParser.Instance.GetHtml(Bookitem.ReadLinkage);

                if (htmlPage == null)
                {
                    await MainPage.PopMessageDialog("已取消收藏!");
                }
                else
                {
                    BookIndexes.Clear();
                    BookIndexParser.Instance.GetBookIndexes(htmlPage, BookIndexes);
                    MainPage.ProgressRing.IsActive   = false;
                    MainPage.ProgressRing.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                }
            }
            else if (e.NavigationMode == NavigationMode.Back)
            {
                MainPage.TitleTextBlock.Text     = localTitle;
                MainPage.ProgressRing.IsActive   = false;
                MainPage.ProgressRing.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }
        }