从 thispersondoesnotexist.com 获取 4 个不同的 c# 图像?

问题描述

我试图从 thispersondoesnotexist.com 中提取 4 个不同的图像,但最终偶尔会得到重复的图像。设置延迟似乎降低了这种情况发生的可能性,但为了消除问题,程序会因延迟而变得非常缓慢。有人可以提出更好的解决方案吗?这是我当前的代码:(参数是这样它不会被兑现)

private void btnStart_Click(object sender,EventArgs e)
        {
            btnStart.Visible = false;
            var random = new Random();
            var randomnumber = random.Next(10,30);
            pbPerson1.Load("https://thispersondoesnotexist.com/image?a=37645734567");
            System.Threading.Thread.Sleep(500);
            pbPerson2.Load("https://thispersondoesnotexist.com/image?a=67834562543");
            System.Threading.Thread.Sleep(500);
            pbPerson3.Load("https://thispersondoesnotexist.com/image?a=33622434768");
            System.Threading.Thread.Sleep(500);
            pbPerson4.Load("https://thispersondoesnotexist.com/image?a=34688707547");
        }

解决方法

该网站通过在计时器上随机生成图像来工作......生成图像需要时间,它并不打算为每个请求检索唯一的图像。

无论如何,这与您的代码无关,您应该直接向网站开发者提出问题(他们的联系方式在主页上:https://thispersondoesnotexist.com/