Ejemplo n.º 1
0
        public void GetRankingFilmLinks(string url)
        {
            AllLinks.Clear();
            System.Console.WriteLine("***********************************");
            System.Console.WriteLine("Pobieram linki filmow z rankingow\n" + url);
            System.Console.WriteLine("***********************************");
            // e.g. http://www.filmweb.pl/rankings/film/country/genre/
            Document = HtmlWeb.Load(url);

            Prepare_links = Document.DocumentNode.Descendants("a");
            foreach (var link in Prepare_links)
            {
                if (link.GetAttributeValue("class", "test") == "s-20")
                {
                    string Link = "http://filmweb.pl" + link.Attributes["href"].Value;
                    AllLinks.Add(Link);
                }
            }
            System.Console.WriteLine("Pobrano linki.");
        }
Ejemplo n.º 2
0
        // Initializes the proper context for each of the steps onTabActivate
        private void tabInterface_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.OriginalSource is TabControl)
            {
                if (tabInterface.SelectedIndex > 0 && System.IO.File.Exists(ioPathLinkList) == false)
                {
                    tabInterface.SelectedIndex = 0;
                }
                else if (tabInterface.SelectedIndex > 1 && System.IO.File.Exists(ioPathLinkObjects) == false)
                {
                    tabInterface.SelectedIndex = 1;
                }
                else if (tabInterface.SelectedIndex == 4 && System.IO.File.Exists(ioPathHelpAbstraction) == false)
                {
                    tabInterface.SelectedIndex = 3;
                }
                else
                {
                    switch (tabInterface.SelectedIndex + 1)
                    {
                    case 1:     // Step 1: Extracting Navigation Links
                        navURL = urlHelpers.getHelpURL("4CEE5072-8817-4920-8A2D-7060F5E16547");
                        break;

                    case 2:     // Step 2: Classify the extracted links
                        AllLinks.Clear();
                        var html             = System.IO.File.ReadAllText(ioPathLinkList);
                        HAP.HtmlDocument doc = new HAP.HtmlDocument();
                        doc.LoadHtml(html);
                        var anchors = doc.DocumentNode.SelectNodes("//a").ToList();
                        foreach (var a in anchors)
                        {
                            var href  = a.GetAttributeValue("href", "").ToUpper().Trim(' ', '?').Replace("GUID-", "").Replace("GUID=", "").Trim();
                            var title = a.InnerText.Replace("\n", "").Replace("\r", "").Replace("&gt;", ">").Replace("&lt;", "<").Trim();
                            AllLinks.Add(new LinkObject(title, href));
                        }
                        navURL = ioPathLinkList;
                        lbxInitNavLinks.ItemsSource = AllLinks;
                        break;

                    case 3:     // Download the classified link conent
                        isIdle = true;
                        InitializeDownloadVariables();
                        break;

                    case 4:     // Parse of web help document content
                        InitializeDownloadVariables();
                        break;

                    case 5:     // possibly some kind of rule system
                        CurrentLib = ioPathHelpAbstraction.UnPack <WebObjectLibrary>();
                        AllOverrides.Clear();
                        Filter = "";
                        if (System.IO.File.Exists(ioPathRuleOverrides) == true)
                        {
                            foreach (OverrideRule item in ioPathRuleOverrides.UnPack <List <OverrideRule> >())
                            {
                                AllOverrides.Add(item);
                            }
                        }
                        tvApplyOverrides.DataContext = CurrentLib;
                        break;
                    }
                }
            }
        }