• 大小: 79.07M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2022-04-17
  • 语言: 其他
  • 标签: 其他  

资源简介

Tess4j.zip

资源截图

代码片段和文件信息

import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HttpContext;

import javax.imageio.ImageIO;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import javax.swing.text.html.HTML;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;

public class GetCode {

    public static void main(String[] args) throws IOException KeyManagementException NoSuchAlgorithmException {
        for (int i = 1; i < 2; i++) {
            //采用绕过验证的方式处理https请求
            SSLContext sslcontext = createIgnoreVerifySSL();

            //设置协议http和https对应的处理socket链接工厂的对象
            Registry socketFactoryRegistry = RegistryBuilder.create()
                    .register(“http“ PlainConnectionSocketFactory.INSTANCE)
                    .register(“https“ new SSLConnectionSocketFactory(sslcontext))
                    .build();
            PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
            HttpClients.custom().setConnectionManager(connManager);


            //创建自定义的httpclient对象
            CloseableHttpClient httpCilent = HttpClients.custom().setConnectionManager(connManager).build();

            HttpGet httpGet = new HttpGet(“https://jiaoyi.jjjpjzx.com/validateCode.do“);
            HttpResponse response = httpCilent.execute(httpGet);
            FileOutputStream out = new FileOutputStream(new File(“aa.png“));
            BufferedImage bi = ImageIO.read(response.getEntity().getContent());
            ImageIO.write(bi “jpeg“ out);
            try {
                httpCilent.execute(httpGet);
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                try {
                    httpCilent.close();//释放资源
                } catch (IOException e) {
 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-08-01 11:32  Tess4j\
     文件        6148  2018-08-01 11:23  Tess4j\.DS_Store
     目录           0  2018-08-01 11:33  __MACOSX\
     目录           0  2018-08-01 11:33  __MACOSX\Tess4j\
     文件         120  2018-08-01 11:23  __MACOSX\Tess4j\._.DS_Store
     目录           0  2018-08-01 11:32  Tess4j\.idea\
     文件         624  2018-07-25 14:46  Tess4j\.idea\compiler.xml
     目录           0  2018-07-25 14:45  Tess4j\.idea\inspectionProfiles\
     文件        1444  2018-07-25 14:45  Tess4j\.idea\inspectionProfiles\Project_Default.xml
     目录           0  2018-07-30 15:08  Tess4j\.idea\libraries\
     文件         556  2018-07-27 16:37  Tess4j\.idea\libraries\Maven__ch_qos_logback_logback_classic_1_2_3.xml
     文件         535  2018-07-27 16:37  Tess4j\.idea\libraries\Maven__ch_qos_logback_logback_core_1_2_3.xml
     文件         595  2018-07-27 16:37  Tess4j\.idea\libraries\Maven__com_github_jai_imageio_jai_imageio_core_1_3_1.xml
     文件         474  2018-07-27 16:37  Tess4j\.idea\libraries\Maven__com_lowagie_itext_2_1_7.xml
     文件         582  2018-07-27 16:37  Tess4j\.idea\libraries\Maven__commons_beanutils_commons_beanutils_1_9_2.xml
     文件         531  2018-07-27 15:46  Tess4j\.idea\libraries\Maven__commons_codec_commons_codec_1_10.xml
     文件         604  2018-07-27 16:37  Tess4j\.idea\libraries\Maven__commons_collections_commons_collections_3_2_1.xml
     文件         491  2018-07-27 16:37  Tess4j\.idea\libraries\Maven__commons_io_commons_io_2_5.xml
     文件         546  2018-07-27 15:46  Tess4j\.idea\libraries\Maven__commons_logging_commons_logging_1_2.xml
     文件         443  2018-07-27 16:37  Tess4j\.idea\libraries\Maven__junit_junit_4_12.xml
     文件         457  2018-07-27 16:37  Tess4j\.idea\libraries\Maven__log4j_log4j_1_2_17.xml
     文件         480  2018-07-27 16:37  Tess4j\.idea\libraries\Maven__net_java_dev_jna_jna_4_1_0.xml
     文件         525  2018-07-27 16:37  Tess4j\.idea\libraries\Maven__net_sourceforge_lept4j_lept4j_1_4_0.xml
     文件         525  2018-07-27 16:37  Tess4j\.idea\libraries\Maven__net_sourceforge_tess4j_tess4j_3_4_0.xml
     文件         565  2018-07-27 15:46  Tess4j\.idea\libraries\Maven__org_apache_httpcomponents_httpclient_4_5_6.xml
     文件         558  2018-07-27 15:46  Tess4j\.idea\libraries\Maven__org_apache_httpcomponents_httpcore_4_4_10.xml
     文件         602  2018-07-27 16:37  Tess4j\.idea\libraries\Maven__org_apache_xmlgraphics_xmlgraphics_commons_1_4.xml
     文件         488  2018-07-27 16:37  Tess4j\.idea\libraries\Maven__org_ghost4j_ghost4j_1_0_1.xml
     文件         520  2018-07-27 16:37  Tess4j\.idea\libraries\Maven__org_hamcrest_hamcrest_core_1_3.xml
     文件         543  2018-07-27 16:37  Tess4j\.idea\libraries\Maven__org_jboss_jboss_vfs_3_2_12_Final.xml
     文件         575  2018-07-27 16:37  Tess4j\.idea\libraries\Maven__org_jboss_logging_jboss_logging_3_1_4_GA.xml
............此处省略1022个文件信息

评论

共有 条评论