using System;
using System.IO;
using System.Linq;
using System.Threading;
using Leaf.xNet;
namespace Avatart_generator
{
internal class Program
{
private static Random random = new Random();
private static readonly string path = "Avatars";
static void Main(string[] args)
{
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
Console.WriteLine("Enter count avatar: ");
int count = Int32.Parse(Console.ReadLine());
for (int i = 0; i < count; i++)
{
using (HttpRequest request = new HttpRequest())
{
request[HttpHeader.Accept] = "image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8";
request.AcceptEncoding = "gzip, deflate";
request[HttpHeader.Referer] = "https://thispersondoesnotexist.com/";
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36";
var response = request.Get("https://thispersondoesnotexist.com/image");
response.ToFile($"{path}\\{RandomString(9)}.jpg");
Thread.Sleep(200);
}
}
Console.WriteLine("Parse done");
Console.ReadKey();
}
public static string RandomString(int length)
{
const string chars = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789";
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray());
}
}
}