- httpget = new HttpGet("http://www.zjgsdx.com/bbs/seccode.php?update=82986);
这个地址是验证码的地址
- httpget.setHeader("Accept", "*/*");
- httpget.setHeader("Accept-Encoding", "gzip, deflate");
- httpget.setHeader("Accept-Language", "en-US");
- httpget.setHeader("Connection", "Keep-Alive");
- httpget.setHeader("Cookie", cookieString);
- httpget.setHeader("Host", "www.zjgsdx.com");
- httpget.setHeader("Referer", "http://www.zjgsdx.com/bbs/logging.php?action=login&referer=http%3A//www.zjgsdx.com/bbs/memcp.php");
- httpget.setHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729)");
- response = httpclient.execute(httpget);
- System.out.println("get verify picture : response.getStatusLine().getStatusCode() = " + response.getStatusLine().getStatusCode());
- System.out.println("Content-Type:" + response.getHeaders("Content-Type")[0].getValue());
- entity = response.getEntity();
- InputStream inputStream = new GzipDecompressingEntity(entity).getContent();
- // write the inputStream to a FileOutputStream
- OutputStream out = new FileOutputStream(new File("c:\\newfile.png"));
- int read = 0;
- byte[] bytes = new byte[1024];
- while ((read = inputStream.read(bytes)) != -1) {
- out.write(bytes, 0, read);
- }
- inputStream.close();
- out.flush();
- out.close();
- System.out.println("Check file c:\\newfile.png");