- Регистрация
- 23.03.2013
- Сообщения
- 25
- Благодарностей
- 4
- Баллы
- 3
Обращаем Ваше внимание на то, что данный пользователь заблокирован.
Не рекомендуем проводить с huangxiangcai_old какие-либо сделки.
We always to use the CapthchaSaver to save the images in the webpage.but there a problem:When the images size out of the range .it can be quit .
so i want to use the C#code to download via HTTP.
The code I got from somewhere can be some problems
Some one help me .Thanks
The C# Code
---------------------------------------------------------------------------
public Bitmap Get_img()
{
Bitmap img = null;
HttpWebRequest req;
HttpWebResponse res = null;
try
{
System.Uri httpUrl = new System.Uri("http://xxx.com/xxx.png ");
req = (HttpWebRequest)(WebRequest.Create(httpUrl));
req.Timeout = 180000;
req.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0";
req.Accept = "en-US,en;q=0.5";
req.Method = "GET";
res = (HttpWebResponse)(req.GetResponse());
img = new Bitmap(res.GetResponseStream());
img.Save(@"E:/" + DateTime.Now.ToFileTime().ToString() + ".png");
}
catch (Exception ex)
{
string aa= ex.Message;
}
finally
{
res.Close();
}
return img;
}
so i want to use the C#code to download via HTTP.
The code I got from somewhere can be some problems
Some one help me .Thanks
The C# Code
---------------------------------------------------------------------------
public Bitmap Get_img()
{
Bitmap img = null;
HttpWebRequest req;
HttpWebResponse res = null;
try
{
System.Uri httpUrl = new System.Uri("http://xxx.com/xxx.png ");
req = (HttpWebRequest)(WebRequest.Create(httpUrl));
req.Timeout = 180000;
req.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0";
req.Accept = "en-US,en;q=0.5";
req.Method = "GET";
res = (HttpWebResponse)(req.GetResponse());
img = new Bitmap(res.GetResponseStream());
img.Save(@"E:/" + DateTime.Now.ToFileTime().ToString() + ".png");
}
catch (Exception ex)
{
string aa= ex.Message;
}
finally
{
res.Close();
}
return img;
}