简体   繁体   English

图片不是由C#,WebRequest.Create(url.AbsoluteUri)作为HttpWebRequest下载的;

[英]Image is not downloading by C# , WebRequest.Create(url.AbsoluteUri) as HttpWebRequest;

Previously all Images were downloadable from different website by using 以前,所有图片都可以使用来从其他网站下载

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

But now,I came across a website 但是现在,我遇到了一个网站

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

and this Image URL is not downloadable 而且此图片网址不可下载

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

Can anybody suggest me please what is the reason? 有人可以建议我这是什么原因吗?

pehaps set the timout with bigger value 可能将timout设置为更大的价值

request.Timeout = 5000;
request.ReadWriteTimeout = 20000;

your site expects an User-Agent header. 您的网站需要一个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);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM