private void DownloadJogos()
        {
            Uteis.Log("", Log);
            Uteis.Log($"[{NomeBase}] Iniciando Download dos jogos...", Log);
            Uteis.Log("", Log);

            Uteis.ValidaDiretorio(UrlSaveDownloads + lista[0]);

            for (int i = 2; i < lista.Count; i++)
            {
                foreach (var jo in linkJogos)
                {
                    if (jo.Nome.Contains(lista[i]))
                    {
                        encontrou = true;
                        using (WebClient client = new WebClient())
                        {
                            client.DownloadFile(jo.Url, $"{UrlSaveDownloads}{lista[0]}/{lista[i]}.7z");

                            Uteis.Log($"{lista[i] + ".7z"}... ", Log);
                        }
                        break;
                    }
                }

                if (!encontrou)
                {
                    erros.Add(lista[i]);
                }
                encontrou = false;
            }
        }
        private void LerArquivos()
        {
            Uteis.Log($"[{NomeBase}] Lendo lista...", Log);

            using (var file = new StreamReader(URL))
            {
                lista = file.ReadToEnd().Split(';').ToList();
            }

            Uteis.Log($"[{NomeBase}] Nome: {lista[0]} URL: {lista[1]} - {lista.Count} Nomes lidos...", Log);
        }
        public void Executar()
        {
            Uteis.Log("-- -----------------------------------------------------------------", Log);

            LerArquivos();
            RasparLisnksNomes();
            DownloadJogos();
            CriarRelatorioErrosTxt();
            MostrarRelatorioFinal(CriarRelatorioFinal);

            Uteis.Log("-- -----------------------------------------------------------------", Log);
        }
        private void CriarRelatorioErrosTxt()
        {
            Uteis.Log("", Log);
            Uteis.Log($"[{NomeBase}] Gerando logs...", Log);

            Uteis.ValidaDiretorio($"{UrlSaveDownloads}log/");

            using (var file = new StreamWriter($"{UrlSaveDownloads}log/{lista[0]}-erros.txt"))
            {
                foreach (var err in erros)
                {
                    file.WriteLine(err);
                }
            }
        }
Esempio n. 5
0
        public List <string> Executar()
        {
            List <string> lista = new List <string>();

            Uteis.Log($"[{NomeBase}] Coletando Top Jogos..", Log);

            using (WebClient client = new WebClient())
            {
                var html = client.DownloadString(Url);

                var htmlDoc = new HtmlDocument();
                htmlDoc.LoadHtml(html);

                try
                {
                    var node = htmlDoc.GetElementbyId("list-of-games").ChildNodes;

                    if (node != null)
                    {
                        foreach (var tag in node)
                        {
                            if (!lista.Contains(tag.InnerHtml.LimpaString()))
                            {
                                lista.Add(tag.InnerHtml.LimpaString());
                            }
                        }
                    }
                }
                catch
                {
                    var node = htmlDoc.DocumentNode.SelectNodes("//table/tr/td/a");

                    if (node != null)
                    {
                        foreach (var tag in node)
                        {
                            if (!lista.Contains(tag.InnerHtml.LimpaString()))
                            {
                                lista.Add(tag.InnerHtml.LimpaString());
                            }
                        }
                    }
                }

                Uteis.Log($"[{NomeBase}] - {lista.Count} nomes coletados..", Log);
            }
            return(lista);
        }
        private void MostrarRelatorioFinal(bool criarRelatorioFinal)
        {
            Uteis.Log("", Log);
            Uteis.Log("", Log);
            Uteis.Log($"            ### Processo Finalizado [{NomeBase}] ###", Log);
            Uteis.Log($"[{NomeBase}] Diretorio com Downloads:........................... {UrlSaveDownloads + lista[0]}", Log);
            Uteis.Log($"[{NomeBase}] Logs:.............................................. {UrlSaveDownloads + @"log\"}", Log);
            Uteis.Log($"[{NomeBase}] Total de nomes de jogos para Download {lista[0]}:.. {lista.Count - 2}", Log);
            Uteis.Log($"[{NomeBase}] Total de Links coletados do emulador {lista[0]}:... {linkJogos.Count}", Log);
            Uteis.Log($"[{NomeBase}] Total de Erros:.................................... {erros.Count}", Log);

            if (criarRelatorioFinal)
            {
                CriarRelatorioFinalTxt();
                Uteis.Log($"[{NomeBase}] Relatorio Final:................................... {UrlSaveDownloads}log/relatorio-{lista[0]}.txt", Log);
            }

            Uteis.Log($"                     ### FIM ###", Log);
        }
Esempio n. 7
0
        static void ExecutaProcesso(object urls)
        {
            Urls u = (Urls)urls;

            Uteis.Log($"[{u.Nome}] Inicio da base..", true);

            RaspaMelhoresJogos topGames = new RaspaMelhoresJogos(u.UrlMelhoresjogos, true, u.Nome);

            var listaMelhoresGames = topGames.Executar();

            using (var file = new StreamWriter($@"{Urlbase}resultado\{u.Nome}.txt"))
            {
                file.Write(u.Nome + ";");
                file.Write(u.UrlDownload);

                foreach (var a in listaMelhoresGames)
                {
                    file.Write(";" + a);
                }
            }

            Uteis.Log($"[{u.Nome}] Iniciando Download..", true);

            DownloadGamesCore core = new DownloadGamesCore
                                     (
                $@"{Urlbase}resultado\{u.Nome}.txt",
                $@"{Urlbase}resultado\",
                true,
                u.Nome.ToString(),
                false
                                     );

            core.Executar();


            Uteis.Log($"[{u.Nome}] Download concluido..", true);

            Uteis.Log($"[{u.Nome}] Fim da base..", true);
        }
        private void RasparLisnksNomes()
        {
            using (WebClient client = new WebClient())
            {
                Uteis.Log("", Log);
                Uteis.Log($"[{NomeBase}] Iniciando raspagem dos Nomes e Links...", Log);

                for (int x = A; x <= Z; x++)
                {
                    string html = client.DownloadString(lista[1].Replace('@', (char)x));

                    var htmlDoc = new HtmlDocument();
                    htmlDoc.LoadHtml(html);

                    var links = htmlDoc.DocumentNode.SelectNodes("//table/tr/td/a");

                    if (links != null)
                    {
                        foreach (var link in links)
                        {
                            linkJogos.Add(new Jogo()
                            {
                                Url  = BaseUrl + link.Attributes["href"].Value,
                                Nome = link.InnerHtml.LimpaString()
                            });
                        }

                        Uteis.Log($"{(char)x}.. {linkJogos.Count} Links coletados", Log);
                    }
                    else
                    {
                        Uteis.Log($"{(char)x}.. NÃO HA DADOS", Log);
                    }
                }
            }
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            DateTime       dataAtual = DateTime.Now;
            Queue <string> listas    = new Queue <string>();

            Uteis.ValidaDiretorio($@"{Urlbase}resultado\");

            List <string> listaUrls;

            using (var file = new StreamReader(UrlArquivo))
            {
                listaUrls = file.ReadToEnd().Split(';').ToList();
            }

            foreach (var u in listaUrls)
            {
                listas.Enqueue(u);
            }

            while (listas.Any())
            {
                Thread t1 = new Thread(ExecutaProcesso);
                Thread t2 = new Thread(ExecutaProcesso);

                var  str_1   = listas.Dequeue();
                bool exec_t2 = false;

                Urls ulrs_1 = new Urls()
                {
                    Nome             = str_1.Split('|')[0].Replace('\n', ' ').Replace('\r', ' ').Trim(),
                    UrlMelhoresjogos = str_1.Split('|')[1],
                    UrlDownload      = str_1.Split('|')[2]
                };

                Uteis.Log("### INICIANDO THREADS..\n", true);

                t1.Start(ulrs_1);

                if (listas.Any())
                {
                    var str_2 = listas.Dequeue();
                    exec_t2 = true;

                    Urls ulrs_2 = new Urls()
                    {
                        Nome             = str_2.Split('|')[0].Replace('\n', ' ').Replace('\r', ' ').Trim(),
                        UrlMelhoresjogos = str_2.Split('|')[1],
                        UrlDownload      = str_2.Split('|')[2]
                    };

                    t2.Start(ulrs_2);
                }

                if (exec_t2)
                {
                    t1.Join();
                    t2.Join();
                }
                else
                {
                    t1.Join();
                }

                Uteis.Log("\n### FINALIZANDO THREADS..\n", true);
            }

            Console.WriteLine($"Inicio: {dataAtual}, Fim: {DateTime.Now}");
            Console.WriteLine($"Total de tempo: {DateTime.Now - dataAtual}");

            Console.WriteLine("###### FIM ######");

            Console.ReadKey();
        }