0

以前所有图像都可以通过使用从不同的网站下载

  var request = WebRequest.Create(url.AbsoluteUri) as HttpWebRequest;  

但是现在,我偶然发现了一个网站

http://www.euroman.dk/gadgets-og-design/det-onsker-vi-os/skyd-360-video-med-din-iphone/

并且此图片网址不可下载

http://www.euroman.dk/imagecropper.ashx?f=%2fUpload%2feuroman-dk%2fgadgets-og-design%2f2013%2520maj%2fthedot_01.jpg&w=643&h=405&m=1

有人可以建议我,请问是什么原因?

4

2 回答 2

0

pehaps 将 timout 设置为更大的值

request.Timeout = 5000;
request.ReadWriteTimeout = 20000;
于 2013-05-30T10:09:05.373 回答
0

您的网站需要一个User-Agent标题。

string url = "http://www.euroman.dk/imagecropper.ashx?f=%2fUpload%2feuroman-dk%2fgadgets-og-design%2f2013%2520maj%2fthedot_01.jpg&w=643&h=405&m=1";
using (WebClient wc = new WebClient())
{
    wc.Headers["User-Agent"] = "Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12";
    byte[] data = wc.DownloadData(url);
}
于 2013-05-30T10:21:37.080 回答