Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using HtmlAgilityPack;
  8.  
  9. namespace ConsoleApplication1
  10. {
  11. class Program
  12. {
  13.  
  14. static void Main(string[] args)
  15. {
  16. string baseUrl = @"http://www.japanesebeauties.net/javhd/hana-haruna/";
  17. string baseFolder = @"C:\Users\pedro\Desktop\";
  18.  
  19. int min = 1;
  20. int max = 86;
  21.  
  22. string idol = "Hana Haruna";
  23. string path = System.IO.Path.Combine(baseFolder, idol);
  24.  
  25. if (!System.IO.Directory.Exists(path))
  26. {
  27. System.IO.Directory.CreateDirectory(path);
  28. }
  29.  
  30. List<string> images = new List<string>();
  31.  
  32. using (WebClient client = new WebClient())
  33. {
  34. for (int i = min; i <= max; i++)
  35. {
  36. Console.Write("Reading gallery " + i.ToString("D2") + "... ");
  37. string source = client.DownloadString(baseUrl + i);
  38. System.Threading.Thread.Sleep(1000);
  39.  
  40. HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
  41. document.LoadHtml(source);
  42. foreach (var link in document.DocumentNode.Descendants("img"))
  43. {
  44. if (!link.Attributes["src"].Value.Contains("ads") && !link.Attributes["src"].Value.Contains("mobile"))
  45. {
  46. images.Add(link.Attributes["src"].Value);
  47. }
  48.  
  49. }
  50.  
  51. Console.WriteLine("OK!");
  52. }
  53. }
  54.  
  55. Console.WriteLine("Number of photos: " + images.Count);
  56.  
  57. for (int i = 0; i < images.Count; i++)
  58. {
  59. using (WebClient webClient = new WebClient())
  60. {
  61.  
  62. string imageName = i.ToString("D3") + ".jpg";
  63. string imagePath = System.IO.Path.Combine(path, imageName);
  64.  
  65. Console.Write("Downloading photo " + i.ToString("D3") + "... ");
  66.  
  67. webClient.DownloadFile(images[i], imagePath);
  68. System.Threading.Thread.Sleep(2000);
  69.  
  70. Console.WriteLine("OK!");
  71. }
  72. }
  73.  
  74.  
  75. Console.Read();
  76. }
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement