Example #1
0
        /// <summary>
        /// Parse all the major links found in some piece of String.
        /// </summary>
        /// <param name="section">The section of the page to search for links.</param>
        /// <param name="cat">The category of the section of the page to search for links.</param>
        /// <param name="media">The type of titles to search (movies or tv series).</param>
        /// <returns>A List of IMDbLink objects.</returns>
        private List <IMDbLink> parseLinks(string section, string cat, int media)
        {
            List <IMDbLink> links   = new List <IMDbLink>();
            string          pat     = @"(<a href=.*?)</td></tr>";
            Regex           reg     = new Regex(pat);
            MatchCollection matches = reg.Matches(section);

            if (matches.Count > 0)
            {
                foreach (Match m in matches)
                {
                    string line = m.Groups[1].Value;
                    line = cleanText(line);
                    pat  = @"<a href=""(.{17})";
                    reg  = new Regex(pat);
                    string url = reg.Match(line).Groups[1].Value;
                    pat = @"<img src=""(.*?)""";
                    reg = new Regex(pat);
                    string cover = reg.Match(line).Groups[1].Value;
                    pat = @";"">(&#34;|"")?(['&,áéíóúàèìòùÁÉÍÓÚÀÈÌÒÙãÃõÕâêÊÂñÑA-Za-z0-9 :\(\)!]*)(&#34;|"")?</a>\s*?\((\d{4}).*?\)";
                    reg = new Regex(pat);
                    Match    mat = reg.Match(line);
                    IMDbLink l   = new IMDbLink();
                    l.Title    = mat.Groups[2].Value;
                    l.Year     = mat.Groups[4].Value;
                    l.URL      = url;
                    l.Cover    = cover;
                    l.Category = cat;
                    pat        = @"<small>(.*?)</small>";
                    reg        = new Regex(pat);
                    if (reg.Match(line).Groups[1].Value != null && reg.Match(line).Groups[1].Value != "")
                    {
                        l.Media = 1;
                    }
                    else
                    {
                        l.Media = 0;
                    }

                    if (l.Media == media)
                    {
                        links.Add(l);
                    }
                }
            }
            return(links);
        }
Example #2
0
        /// <summary>
        /// Parse all the major links found in some piece of String.
        /// </summary>
        /// <param name="section">The section of the page to search for links.</param>
        /// <param name="cat">The category of the section of the page to search for links.</param>
        /// <param name="media">The type of titles to search (movies or tv series).</param>
        /// <returns>A List of IMDbLink objects.</returns>
        private List<IMDbLink> parseLinks(string section, string cat, int media)
        {
            List<IMDbLink> links = new List<IMDbLink>();
            string pat = @"(<a href=.*?)</td></tr>";
            Regex reg = new Regex(pat);
            MatchCollection matches = reg.Matches(section);

            if (matches.Count > 0)
            {
                foreach (Match m in matches)
                {
                    string line = m.Groups[1].Value;
                    line = cleanText(line);
                    pat = @"<a href=""(.{17})";
                    reg = new Regex(pat);
                    string url = reg.Match(line).Groups[1].Value;
                    pat = @"<img src=""(.*?)""";
                    reg = new Regex(pat);
                    string cover = reg.Match(line).Groups[1].Value;
                    pat = @";"">(&#34;|"")?(['&,áéíóúàèìòùÁÉÍÓÚÀÈÌÒÙãÃõÕâêÊÂñÑA-Za-z0-9 :\(\)!]*)(&#34;|"")?</a>\s*?\((\d{4}).*?\)";
                    reg = new Regex(pat);
                    Match mat = reg.Match(line);
                    IMDbLink l = new IMDbLink();
                    l.Title = mat.Groups[2].Value;
                    l.Year = mat.Groups[4].Value;
                    l.URL = url;
                    l.Cover = cover;
                    l.Category = cat;
                    pat = @"<small>(.*?)</small>";
                    reg = new Regex(pat);
                    if (reg.Match(line).Groups[1].Value != null && reg.Match(line).Groups[1].Value != "")
                        l.Media = 1;
                    else l.Media = 0;
                    
                    if(l.Media == media)
                        links.Add(l);
                }
            }
            return links;
        }