继上一篇文章,由于本地限制,等后续整理在一起
2015-08-13 11:21
267 查看
参考例子:
Http获取图片,既可以通过链接地址,直接用Image的Location=URL也可以将图片流获取到本地,这样请求可以得到图片的Cookie,以便有些验证码存储在Cookie中,可以模拟验证码。
byte[] image = File.ReadAllBytes(Environment.CurrentDirectory + @"\AnswerCode.gif"); var param = new Dictionary<object, object> { {"username","test123"}, {"password","123456"}, {"typeid","3040"}, {"timeout","90"} }; string _tempcodehtml = ""; _tempcodehtml = httph.PostImage(urlcode, param, image);
Http获取图片,既可以通过链接地址,直接用Image的Location=URL也可以将图片流获取到本地,这样请求可以得到图片的Cookie,以便有些验证码存储在Cookie中,可以模拟验证码。
public Bitmap GetImage(string url, ref CookieContainer cookie, string refer) { HttpWebRequest hrq = (HttpWebRequest)WebRequest.Create(url); hrq.Method = "GET"; try { HttpWebResponse hrp = (HttpWebResponse)hrq.GetResponse(); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(hrp.GetResponseStream()); if (cookie == null) { cookie.GetCookies(hrq.RequestUri); } hrp.Close(); return bmp; } catch (Exception) { return null; } }
相关文章推荐
- Chrome浏览器中的网上应用店如何加载
- mysql多字段唯一索引
- Java int和integer的区别
- div+css3纯手工制作登录页
- 任务单案例一
- Ubuntu系统下的Hadoop集群(6)_Hadoop安装配置简略教程
- 浅谈C/C++内存泄漏及其检测工具
- POJ 3620 Avoid The Lakes【DFS】
- java程序由mysql转到sqlserver时在浮点数处理上遇到的错误
- UVA 11584 Partitioning by Palindromes 划分回文串 (Manacher算法)
- Java DecimalFormat 用法
- 实际iOS编程中遇到的自定义导航栏按钮,导致手势返回失效的解决方法
- 在spring官网下载jar包、源码、文档
- Bit Manipulation - Number of 1 Bits
- SpringMVC表单标签(6)
- Android结合volley的netWorkImageview实现图片文件缓存
- 安装samba后在init.d文件夹没有smb
- 安装samba后在init.d文件夹没有smb
- remove '^M' in shell script
- c# winform 模拟web post图片