c# - WebClient.DownloadData 返回状态码 444
问题描述
我正在尝试从 url 下载图像,但出现“远程服务器返回错误:(444)无响应”之类的异常。
这是下载图像的代码
string url = "https://listing-images.homejunction.com/bright/304545918990/photo_20.jpg";
System.Threading.Thread.Sleep(1000);
using (WebClient wc = new WebClient())
{
byte[] byteUrl = wc.DownloadData(url);
Image orgImg = Bitmap.FromStream(new MemoryStream(byteUrl));
Bitmap bmpImage = new Bitmap(orgImg);
Bitmap bmpCrop = bmpImage.Clone(new Rectangle(0, 0, orgImg.Width, orgImg.Height - CropSize), bmpImage.PixelFormat);
MemoryStream memoryStream = new MemoryStream();
bmpCrop.Save(memoryStream, orgImg.RawFormat);
return memoryStream;
}
解决方案
推荐阅读
- phpmyadmin - phpmyadmin 不显示登录表单,只显示徽标
- python - 有没有更好的方法将一个元素加到一个不同长度的列表中?
- java - 调用方法时如何等待特定线程完成
- node.js - 如何在 GraphQL 查询响应中获得已弃用的警告
- html - 在徽标下方添加导航栏并将内容居中
- javascript - 使用 JavaScript 或 jQuery 或 CSS将鼠标悬停在单个标签下的各种元素上时如何添加不同的样式
- python - 如何根据共同日期在单个数据框中对齐两个数据框的数据
- r - 是否有一个 testthat expect_* 函数用于比较两个对象的行为?
- flutter - 如何为以下数据创建控制器?
- flutter - 从抽屉退出时返回登录,无论如何