首页 > 解决方案 > 从 thispersondoesnotexist.com 在 c# 中获取 4 个不同的图像?

问题描述

我试图从 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");
        }

标签: c#imagemedia

解决方案


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

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


推荐阅读