不知道为何获取不到??
1 <%@ Page Language="C#" %>
2 <%@ Import Namespace="System.Net" %>
3 <%@ Import Namespace="System.IO" %>
4 <%
5 string url = Request.QueryString["url"];
6 if (url != null)
7 {
8 if (Uri.IsWellFormedUriString(url, UriKind.Absolute))
9 {
10 Uri uri = new Uri(url);
11 HttpWebRequest WR = (HttpWebRequest)WebRequest.Create(uri);
12 WR.Method = "GET";
13 WR.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
14 WR.UserAgent = "Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2";
15 WR.KeepAlive = false;
16 WR.AllowAutoRedirect = false;
17 WR.Referer = uri.Host;
18 WR.Timeout = 1000;
19 Response.ContentType = WR.ContentType;
20
21 using (WebResponse wr = WR.GetResponse())
22 {
23 StreamReader sr = new StreamReader(wr.GetResponseStream());
24 Response.Write(sr.ReadToEnd());
25 sr.Close();
26 wr.Close();
27 }
28 }
29 }
30 %>
WebRequest wreq = WebRequest.Create(picurl);
wreq.Timeout = 10000;
HttpWebResponse wresp = (HttpWebResponse)wreq.GetResponse();
Stream s = wresp.GetResponseStream();
System.Drawing.Image img = System.Drawing.Image.FromStream(s);
img.Save(filename, ImageFormat.Jpeg);
img.Dispose();
s.Dispose();
这是我的,你参考一下