예제 #1
0
        public static void StartProcessH(string url, string cod, string originalPath)
        {
            string[]  opt    = { "headless" };
            WebDriver driver = new WebDriver(opt);

            try
            {
                driver.Url = url + cod;

                string nome = driver.WaitElement(By.XPath("//*[@id='info']/h1")).Text;

                nome = nome.NormalizeText();

                driver.WaitElement(By.XPath("//*[@id='cover']/a")).Click();

                string pathLog = Path.Combine(originalPath, nome);
                string path    = Path.Combine(originalPath, nome);

                Generic.CreateDirectory(path);

                int contador = 1;
                Generic.file = "Iniciando Download";

                while (true)
                {
                    url = driver.WaitElement(By.XPath("//*[@id='image-container']/a/img")).GetAttribute("src");

                    string newPath = path + "\\" + contador.ToString("00") + ".jpg";

                    Generic.DownloadFile(url, newPath);

                    Generic.file = "Página " + contador.ToString("00") + " baixada";

                    if (driver.ElementIsVisible(By.XPath("//*[@class='reader-pagination']/*[@class='next']"), out var botao))
                    {
                        botao.Click();
                    }
                    else
                    {
                        break;
                    }

                    contador++;
                }
                Generic.file = "Download Concluído";
                Generic.file = "Fim da Execução";
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                driver.Dispose();
            }
        }
예제 #2
0
        public static void StartProcessH(string url, string cod, string originalPath)
        {
            try
            {
                HtmlWeb      get  = new HtmlWeb();
                HtmlDocument page = get.Load(url + cod);

                string nome = page.DocumentNode.SelectSingleNode("//*[@id='info']/h1").InnerText;

                nome = nome.NormalizeText();
                nome = nome.ReplaceChar();

                string pathLog = Path.Combine(originalPath, nome);
                string path    = Path.Combine(originalPath, nome);

                Generic.CreateDirectory(path);

                int contador = 1;
                Generic.file = "Iniciando Download";

                while (true)
                {
                    page = get.Load(url + cod + "/" + contador);
                    string nUrl = string.Empty;

                    try
                    {
                        nUrl = page.DocumentNode.SelectSingleNode("//*[@id='image-container']/a/img").Attributes["src"].Value;
                    }
                    catch
                    {
                        break;
                    }

                    string newPath = path + "\\" + contador.ToString("00") + ".jpg";

                    Generic.DownloadFile(nUrl, newPath);

                    Generic.file = "Página " + contador.ToString("00") + " baixada";

                    contador++;
                }
                Generic.file = "Download Concluído";
                Generic.file = "Fim da Execução";
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #3
0
        public static void StartProcess(string url, string nomeDoManga, int capitulo, int volume, string originalPath, int volNumber)
        {
            string[]  opt    = { "headless" };
            WebDriver driver = new WebDriver(opt);

            nomeDoManga = nomeDoManga.NormalizeFirstText();

            try
            {
                driver.Url = url;

                var searchBox = driver.WaitElement(By.XPath("//*[@id=\"pesquisa\"]"));
                searchBox.SendKeys(nomeDoManga);
                searchBox.Submit();

                driver.WaitElement(By.XPath("/html/body/div[1]/div/div[1]/div[6]/div[1]/a[2]")).Click();

                nomeDoManga = driver.WaitElement(By.XPath("/html/body/div[1]/div/div[1]/div[1]/div/h2")).Text;

                nomeDoManga = nomeDoManga.NormalizeText();

                var capitulos = driver.WaitElements(By.XPath("//*[@class='row lancamento-linha']/div[1]/a"));

                List <string> capUrl   = new List <string>();
                List <string> capTitle = new List <string>();

                foreach (var item in capitulos)
                {
                    capUrl.Insert(0, item.GetAttribute("href"));
                    capTitle.Insert(0, item.Text);
                }

                string pathLog = Path.Combine(originalPath, nomeDoManga);

                if (volume > 0)
                {
                    int volCount = volNumber;

                    string path = Path.Combine(originalPath, nomeDoManga + "\\" + "Volume " + volCount);

                    Generic.CreateDirectory(path);

                    int pageNumber = 1;

                    for (int i = capitulo - 1; i < capUrl.Count; i++)
                    {
                        pageNumber = Generic.OpenVol(driver, capUrl[i], path, pageNumber);

                        if ((i + 1) % volume == 0)
                        {
                            volCount++;
                            pageNumber = 1;
                            path       = Path.Combine(originalPath, nomeDoManga + "\\" + "Volume " + volCount);

                            if (i + 1 < capUrl.Count)
                            {
                                Generic.CreateDirectory(path);
                            }
                        }
                    }
                }
                else
                {
                    for (int i = capitulo - 1; i < capUrl.Count; i++)
                    {
                        string path = Path.Combine(originalPath, nomeDoManga + "\\" + capTitle[i]);

                        Generic.CreateDirectory(path);

                        Generic.file = capTitle[i] + " - Iniciando Download";

                        Generic.OpenCap(driver, capUrl[i], path);

                        File.AppendAllText(pathLog + "\\log.txt", capTitle[i] + " Baixado \r\n");
                        Generic.file = capTitle[i] + " - Download Terminado";
                    }
                }

                Generic.file = "Fim da Execução";
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                driver.Dispose();
            }
        }
예제 #4
0
        public static void StartProcess(string url, string nomeDoManga, int capitulo, int volume, string originalPath, int volNumber)
        {
            try
            {
                nomeDoManga = nomeDoManga.RemoveSpecialChar();
                nomeDoManga = nomeDoManga.Replace(" ", "-").ToLower();
                HtmlWeb      get  = new HtmlWeb();
                HtmlDocument page = get.Load(url + nomeDoManga);

                nomeDoManga = page.DocumentNode.SelectSingleNode("/html/body/div[1]/div/div[1]/div[1]/div/h2").InnerText;

                nomeDoManga = nomeDoManga.NormalizeText();

                var chapters = page.DocumentNode.SelectNodes("//*[@class='row lancamento-linha']/div[1]/a");

                List <string> capUrl   = new List <string>();
                List <string> capTitle = new List <string>();

                foreach (var item in chapters)
                {
                    capUrl.Insert(0, item.Attributes["href"].Value);
                    capTitle.Insert(0, item.InnerText);
                }

                string pathLog = Path.Combine(originalPath, nomeDoManga);

                if (volume > 0)
                {
                    int volCount = volNumber;

                    string path = Path.Combine(originalPath, nomeDoManga + "\\" + "Volume " + volCount);

                    Generic.CreateDirectory(path);

                    int pageNumber = 1;

                    for (int i = capitulo - 1; i < capUrl.Count; i++)
                    {
                        pageNumber = Generic.OpenVol(capUrl[i], path, pageNumber);

                        if ((i + 1) % volume == 0)
                        {
                            volCount++;
                            pageNumber = 1;
                            path       = Path.Combine(originalPath, nomeDoManga + "\\" + "Volume " + volCount);

                            if (i + 1 < capUrl.Count)
                            {
                                Generic.CreateDirectory(path);
                            }
                        }
                    }
                }
                else
                {
                    for (int i = capitulo - 1; i < capUrl.Count; i++)
                    {
                        string path = Path.Combine(originalPath, nomeDoManga + "\\" + capTitle[i]);

                        Generic.CreateDirectory(path);

                        Generic.file = capTitle[i] + " - Iniciando Download";

                        Generic.OpenCap(capUrl[i], path);

                        File.AppendAllText(pathLog + "\\log.txt", capTitle[i] + " Baixado \r\n");
                        Generic.file = capTitle[i] + " - Download Terminado";
                    }
                }
                Generic.file = "Fim da Execução";
            }
            catch (Exception e)
            {
                throw e;
            }
        }