根据URL 返回HTML 根据URL--获取图片信息

/// <summary>
/// 根据URL 返回HTML
/// </summary>
private List<string> GetHtmlByUrl(string Url)
{
WebClient client = new WebClient();
byte[] page = client.DownloadData(Url);
string content = System.Text.Encoding.UTF8.GetString(page);
List<string> _list = GetImgUrlByHtmlText(content);
return _list;
}

 

/---------------------根据URL--获取图片信息--------------/

//后缀名
string _suffix = _imgurls[i].Substring(_imgurls[i].Length - 4);
//图片文件名
string _imageInputTitle = "云鼎宝贝" + DateTime.Now.ToString("yyyyMMddhhmmss" + i) + _suffix;
System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(_imgurls[i]);
webRequest.Method = "GET";
System.Net.HttpWebResponse webResponse = (System.Net.HttpWebResponse)webRequest.GetResponse();
//获取图片保存到流
System.IO.Stream _stream = webResponse.GetResponseStream();
//保存到图片
System.Drawing.Image _image = System.Drawing.Image.FromStream(_stream);

// int _picwidth = _imgWidth.Length <= 0 ? _image.Width : Convert.ToInt32(_imgWidth);
// int _picheight = _imgHeight.Length <= 0 ? _image.Height : Convert.ToInt32(_imgHeight);

//根据参数形成缩略图
//_image = _image.GetThumbnailImage(_image.Width, _image.Height, null, IntPtr.Zero);

//实例化MemoryStream
System.IO.MemoryStream _ImageMem = new System.IO.MemoryStream();

//实例化图片格式
//ImageFormat _imgFormat = new ImageFormat(new Guid());

//根据图片后缀名判断类型.
// if (_suffix.ToLower().Equals(".jpg")) _imgFormat = ImageFormat.Jpeg;
// if (_suffix.ToLower().Equals(".png")) _imgFormat = ImageFormat.Png;
// if (_suffix.ToLower().Equals(".gif")) _imgFormat = ImageFormat.Gif;

//保存
_image.Save(_ImageMem, _image.RawFormat);
//转换为字节流
byte[] _ImageBytes = _ImageMem.GetBuffer();
//释放资源
_image.Dispose();
//关闭流
_stream.Close();

根据URL 返回HTML 根据URL--获取图片信息,布布扣,bubuko.com

根据URL 返回HTML 根据URL--获取图片信息

上一篇:linux设置系统变量


下一篇:【js】右下角浮动窗口