Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Text;
- using System.Threading.Tasks;
- using HtmlAgilityPack;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- string baseUrl = @"http://www.japanesebeauties.net/javhd/hana-haruna/";
- string baseFolder = @"C:\Users\pedro\Desktop\";
- int min = 1;
- int max = 86;
- string idol = "Hana Haruna";
- string path = System.IO.Path.Combine(baseFolder, idol);
- if (!System.IO.Directory.Exists(path))
- {
- System.IO.Directory.CreateDirectory(path);
- }
- List<string> images = new List<string>();
- using (WebClient client = new WebClient())
- {
- for (int i = min; i <= max; i++)
- {
- Console.Write("Reading gallery " + i.ToString("D2") + "... ");
- string source = client.DownloadString(baseUrl + i);
- System.Threading.Thread.Sleep(1000);
- HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
- document.LoadHtml(source);
- foreach (var link in document.DocumentNode.Descendants("img"))
- {
- if (!link.Attributes["src"].Value.Contains("ads") && !link.Attributes["src"].Value.Contains("mobile"))
- {
- images.Add(link.Attributes["src"].Value);
- }
- }
- Console.WriteLine("OK!");
- }
- }
- Console.WriteLine("Number of photos: " + images.Count);
- for (int i = 0; i < images.Count; i++)
- {
- using (WebClient webClient = new WebClient())
- {
- string imageName = i.ToString("D3") + ".jpg";
- string imagePath = System.IO.Path.Combine(path, imageName);
- Console.Write("Downloading photo " + i.ToString("D3") + "... ");
- webClient.DownloadFile(images[i], imagePath);
- System.Threading.Thread.Sleep(2000);
- Console.WriteLine("OK!");
- }
- }
- Console.Read();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement