예제 #1
0
        private void GetCinemaInfo(string lineHtml)
        {
            if (!lineHtml.Equals(string.Empty))
            {
                if (lineHtml.Contains("col-xs-12 col-sm-12 col-md-3 txt"))
                {
                    _addingAddress = true;
                }

                if (_addingAddress)
                {
                    if (!lineHtml.Trim().Equals("<p>") && !lineHtml.Trim().Equals("</div>") && !lineHtml.Trim().Contains("maps") && !lineHtml.Trim().Contains("col-xs-12 col-sm-12 col-md-3 txt") && lineHtml.Trim().Length > 0)
                    {
                        Cinema.Address = CinevoStrings.RemoveChars(lineHtml, '\t');
                        _addingAddress = false;
                    }
                }

                if (lineHtml.Contains("Tel:"))
                {
                    Cinema.Telephone = CinevoStrings.GetChunk(lineHtml, "</strong> ", "</p>");
                }

                if (lineHtml.Contains("Venta Golfas:"))
                {
                    Cinema.NightPasses = CinevoStrings.GetChunk(lineHtml, "</strong> ", "</p>");
                }

                if (lineHtml.Contains("Matinales:"))
                {
                    Cinema.MorningPasses = CinevoStrings.GetChunk(lineHtml, "</strong> ", "</p>");
                }

                if (lineHtml.Contains("Día del espectador:"))
                {
                    Cinema.CheapDay = CinevoStrings.GetChunk(lineHtml, "</strong> ", "</p>");
                }

                if (lineHtml.Contains("Venta anticipada:"))
                {
                    Cinema.OnlineTickets = CinevoStrings.GetChunk(lineHtml, "</strong> ", "</p>");
                }

                if (lineHtml.Contains("<img src="))
                {
                    Cinema.MapUrl = CinevoStrings.GetChunk(lineHtml, "<img src=", ">");
                }

                if (Cinema.MapUrl != null)
                {
                    SetMapValues();
                }
            }
        }
예제 #2
0
        public void ScrapeHtml(string path)
        {
            string files = Directory.GetFiles(path).ToList().First(x => x.Contains(Film.Tag));

            Console.WriteLine("Scraping film -> " + Film.Name);
            Console.WriteLine("----\n");
            if (!string.IsNullOrEmpty(files))
            {
                var    fileReader = new StreamReader(files);
                string line;

                bool updatingDescription = false;

                while ((line = fileReader.ReadLine()) != null)
                {
                    line = CinevoStrings.RemoveChars(line, '\u0009');

                    //---------------

                    if (updatingDescription)
                    {
                        Film.Description = CinevoStrings.StripHtml(line).TrimStart().TrimEnd();
                    }

                    if (line.Contains(StartDescription))
                    {
                        updatingDescription = true;
                    }

                    if (!String.IsNullOrEmpty(Film.Description))
                    {
                        updatingDescription = false;
                    }

                    //---------------

                    if (line.Contains(StartTrailer) && Film?.Trailer == null)
                    {
                        Film.Trailer = CinevoStrings.GetChunk(line, "src=\"", "\" frameborder");
                    }

                    if (line.Contains(StartActors))
                    {
                        Film.Actors = CinevoStrings.StripHtml(line).Replace(StartActors, string.Empty).TrimStart().TrimEnd();
                    }

                    if (line.Contains(StartDirector))
                    {
                        Film.Director = CinevoStrings.StripHtml(line).Replace(StartDirector, string.Empty).TrimStart().TrimEnd();
                    }

                    if (line.Contains(StartEstreno))
                    {
                        Film.FirstShown = CinevoStrings.StripHtml(line).Replace(StartEstreno, string.Empty).TrimStart().TrimEnd();
                    }

                    if (line.Contains(StartGenre))
                    {
                        Film.Genre = CinevoStrings.StripHtml(line).Replace(StartGenre, string.Empty).TrimStart().TrimEnd();
                    }

                    if (line.Contains(StartDuration))
                    {
                        Film.Durantion = CinevoStrings.StripHtml(line).Replace(StartDuration, string.Empty).TrimStart().TrimEnd();
                    }

                    if (line.Contains(StartCountry))
                    {
                        Film.Country = CinevoStrings.StripHtml(line).Replace(StartCountry, string.Empty).TrimStart().TrimEnd();
                    }
                }
                fileReader.Close();
                fileReader.Dispose();
            }
        }