public static void ProcessManazero(string url) { Task.Run(() => { var sw = new SeleniumWrapper(); MainWindow.Instance.Fade_MiddlePopup(true, "접속중..."); sw.Navigate(url); try { sw.ClickXPath("//a[@class='maia-button maia-button-primary']"); } catch { } var title = ManazeroParser.ParseTitle(sw.GetHtml()); var articles = ManazeroParser.ParseArticles(sw.GetHtml()); MainWindow.Instance.ModifyText_MiddlePopup($"가져오는중...[0/{articles.Count}]"); for (int i = 0; i < articles.Count; i++) { sw.Navigate(articles[i].ArticleLink); if (i == 0) { try { sw.ClickXPath("//a[@class='maia-button maia-button-primary']"); } catch { } } articles[i].ImagesLink = ManazeroParser.ParseImages(sw.GetHtml()); MainWindow.Instance.ModifyText_MiddlePopup($"가져오는중...[{i + 1}/{articles.Count}]"); } sw.Close(); int count = 0; foreach (var article in articles) { string dir = Path.Combine(Path.Combine(Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "manazero"), DeleteInvalid(title)), DeleteInvalid(article.Title)); Directory.CreateDirectory(dir); var se = Koromo_Copy.Interface.SemaphoreExtends.MakeDefault(); se.Referer = url; count += article.ImagesLink.Count; DownloadSpace.Instance.RequestDownload($"manazero: {article.Title}", article.ImagesLink.ToArray(), article.ImagesLink.Select(x => Path.Combine(dir, HttpUtility.UrlDecode(HttpUtility.UrlDecode(x.Split('/').Last())))).ToArray(), se, dir + '\\', null ); } MainWindow.Instance.FadeOut_MiddlePopup($"{count}개({articles.Count} 작품) 항목 다운로드 시작..."); }); }
public static void ProcessPinterest(string url) { Task.Run(async() => { string user = Regex.Match(url, "pinterest.co.kr/(.*?)/").Groups[1].Value; var sw = new SeleniumWrapper(); MainWindow.Instance.Fade_MiddlePopup(true, "접속중..."); sw.Navigate(url); sw.WaitComplete(); sw.ClickXPath("//div[@data-test-id='loginButton']"); MainWindow.Instance.ModifyText_MiddlePopup("로그인중..."); sw.SendKeyId("email", Settings.Instance.Pinterest.Id); sw.SendKeyId("password", Settings.Instance.Pinterest.Password); sw.ClickXPath("//div[@data-test-id='registerFormSubmitButton']"); await Task.Delay(10000); sw.WaitComplete(); sw.Navigate($"https://www.pinterest.co.kr/{user}/pins/"); await Task.Delay(5000); sw.WaitComplete(); List <string> images = new List <string>(); string last; do { last = sw.GetHeight(); sw.ScrollDown(); await Task.Delay(2000); foreach (var image in PinParser.ParseImage(sw.GetHtml())) { if (!images.Contains(image)) { images.Add(image); MainWindow.Instance.ModifyText_MiddlePopup($"가져오는중... [{images.Count}]"); } } } while (last != sw.GetHeight()); int height = Convert.ToInt32(sw.GetHeight()); for (int i = 0; i < height; i += 50) { sw.Scroll(i); await Task.Delay(1); foreach (var image in PinParser.ParseImage(sw.GetHtml())) { if (!images.Contains(image)) { if (!images.Contains(image)) { images.Add(image); MainWindow.Instance.ModifyText_MiddlePopup($"재 수집중... [{images.Count}]"); } } } } sw.Close(); string dir = Path.Combine(Settings.Instance.Pinterest.Path, DeleteInvalid(user)); Directory.CreateDirectory(dir); var se = Koromo_Copy.Interface.SemaphoreExtends.MakeDefault(); se.Referer = "https://www.pinterest.co.kr/"; DownloadSpace.Instance.RequestDownload($"pinterest: {user}", images.ToArray(), images.Select(x => Path.Combine(dir, x.Split('/').Last())).ToArray(), se, dir + '\\', null ); MainWindow.Instance.FadeOut_MiddlePopup($"{images.Count}개 항목 다운로드 시작..."); }); }
private void SeriesManagerElements_Loaded(object sender, RoutedEventArgs e) { Task.Run(() => { if (!string.IsNullOrEmpty(url)) { manager = SeriesInfo.Instance.SelectManager(url); if (manager == null) { Application.Current.Dispatcher.BeginInvoke(new Action( delegate { Title.Foreground = Brushes.Red; Title.Text = "오류 - 만족하는 URL 유형을 찾을 수 없습니다.\r\n옳바른 URL인지 확인해주세요.\r\nURL: " + url; CollectStatusPanel.Visibility = Visibility.Collapsed; init_error = true; })); return; } if (manager.EngineType == ManagerEngineType.UsingDriver) { wrapper = new SeleniumWrapper(); } string top_html = ""; string inner_counts = ""; var wc = manager.GetWebClient(); if (wrapper == null) { if (wc != null) { top_html = wc.DownloadString(url); } else { top_html = NetCommon.DownloadString(url); } } switch (manager.Type) { case ManagerType.SingleArticleSingleImage: { } break; case ManagerType.SingleArticleSingleMovie: { } break; case ManagerType.SingleArticleMultipleImages: { if (wrapper == null) { article = manager.ParseArticle(top_html); } else { wrapper.Navigate(url); try { wrapper.ClickXPath("//a[@class='maia-button maia-button-primary']"); } catch { } article = manager.ParseArticle(wrapper.GetHtml()); } title = article.Title; thumbnail = article.Thumbnail; inner_counts = $"사진 {article.ImagesLink.Count}장"; } break; case ManagerType.SingleSeriesMultipleArticles: { if (wrapper == null) { series = manager.ParseSeries(top_html); } else { wrapper.Navigate(url); try { wrapper.ClickXPath("//a[@class='maia-button maia-button-primary']"); } catch { } series = manager.ParseSeries(wrapper.GetHtml()); } title = series.Title; thumbnail = series.Thumbnail; inner_counts = $"작품 {series.Articles.Count}개"; } break; } Application.Current.Dispatcher.BeginInvoke(new Action( delegate { if (!string.IsNullOrEmpty(thumbnail)) { LoadThumbnail(thumbnail); } Title.Text = title; SiteName.Text = manager.Name; LatestSyncDate.Text = MakeSyncDate(new TimeSpan(0, 0, 0, 0)); InnerSitesCount.Text = inner_counts; DownloadState.Text = "다운로드 중"; })); Task.Run(() => StartFirstDownloads()); } }); }