package com.elab.spring.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.elab.core.aop.annotations.EnableElabDB;
import com.elab.core.utils.GzipUtils;
import com.elab.spring.callback.IRestFallback;
import com.elab.spring.callback.impl.DefaultRestFallBack;
import com.elab.spring.dao.MngHttpFailureDataDao;
import com.elab.spring.dao.entity.MngHttpInfoEntity;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.client.RestTemplate;

import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.zip.GZIPInputStream;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = {DefaultRestFallBack.class})
@EnableElabDB(basePackageClasses = {MngHttpFailureDataDao.class, MngHttpInfoEntity.class})
public class RestTemplateUtilsTest {


    @Autowired
    private IRestFallback restFallBack;

    private RestTemplateUtils restTemplateUtils = new RestTemplateUtils();

    private RestTemplate restTemplate = new RestTemplate();

    @Test
    public void post() {
        String url = "http://106.14.133.2:5555/elab-marketing-user//ipAddr/getIpAddr";
        String post = restTemplateUtils.post(url, null, String.class);
        System.out.println("--->" + post);
        Assert.assertNotNull(post);
    }

    @Test
    public void httpsPost() {
        String url = "https://my.jianye.com.cn:19051/MIPApiAuth/Token";
        String data = "{\n" +
                "\t\"client_id\": \"建业云平台\",\n" +
                "\t\"client_secret\": \"fbc670f03fd2bd0\"\n" +
                "}";
        JSONObject jsonObject = JSON.parseObject(data);
        String post = restTemplateUtils.post(url, jsonObject, String.class);
        System.out.println("--->" + post);
        Assert.assertNotNull(post);
    }

    @Test
    public void httpsPost2() {
        String url = "https://apit.centralchina.com:9443/env-101/por-ext/jy001/infos/handler?apikey=OluJj80Kne2koiSMIdX0kfCKwfpQa6LB";
        String data = "{\"AppKey\":\"5c4dee0c0752e0acc5fd6da1ad34321d\",\"PostData\":[{\"Consumer\":\"测试用户\",\"PrjName\":\"建业橙园\",\"Phone\":\"12399009988\",\"Guid\":\"93A92CBE-497E-E711-8ED9-0025907D1F8D\",\"Place\":\"建业云\",\"Create_Time\":\"2020-06-18 11:17:19\"}]}";
        JSONObject jsonObject = JSON.parseObject(data);
        String post = restTemplateUtils.post(url, jsonObject, String.class);
        System.out.println("--->" + post);
        Assert.assertNotNull(post);
    }

    @Test
    public void get() {
        String url = "http://www.baidu.com";
        String get = restTemplateUtils.get(url, String.class);
        System.out.println("--->" + get);
        Assert.assertNotNull(get);
    }


    @Test
    public void delete() {
        String url = "http://localhost:5800/test";
        Map<String, String> req = new HashMap<>();
        req.put("abc", "asdsfd");
        JSONObject get = restTemplateUtils.delete(url, null, req, JSONObject.class);
        System.out.println("--->" + get);
        Assert.assertNotNull(get);
    }

    @Test
    public void getBody() {
        String url = "https://api-test-e.source3g.com/third-face-detect/foreign/face/customer/detail";
        String body = "{\n" +
                "    \"ak\":\"dfcf9588869c4679af62592d2b8488fa\",\n" +
                "    \"nonce\":\"602933e0cb0b4ab798043627f760bf49\",\n" +
                "    \"ts\":\"1603345255\",\n" +
                "    \"sign\":\"8fe0bb25f735e6982b4523cf7c1bb116\",\n" +
                "    \"projectId\":\"b7a782741f667201b54880c925faec4b\",\n" +
                "    \"idNumber\":\"110101198904072992\"\n" +
                "}";

        String s = restTemplateUtils.get(url, JSON.parseObject(body), String.class, null, null);
        System.out.println(s);
    }

    public static String conventFromGzip(String str) throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ByteArrayInputStream in;
        GZIPInputStream gunzip = null;

        in = new ByteArrayInputStream(str.getBytes("ISO-8859-1"));
        gunzip = new GZIPInputStream(in);
        byte[] buffer = new byte[256];
        int n;
        while ((n = gunzip.read(buffer)) >= 0) {
            out.write(buffer, 0, n);
        }
        return out.toString();
    }

    @Test
    public void getInputstream() throws IOException {
        String url = "http://wthrcdn.etouch.cn/weather_mini?city=上海";
        byte[] bytes = restTemplateUtils.get(url, byte[].class);
        String s1 = GzipUtils.unZip(bytes);
        System.out.println(s1);
        Assert.assertTrue(s1.startsWith("{\"data\":"));
    }

    @Test
    public void httpFallBack() throws Exception {
        restTemplateUtils.setRestFallback(restFallBack);
//        String url = "https://my.jianye.com.cn:19051/MIPApiAuth/Token";
//        String data = "{\n" +
//                "\t\"client_id\": \"建业云平台\",\n" +
//                "\t\"client_secret\": \"fbc670f03fd2bd0\"\n" +
//                "}";
        String url = "https://elab-lkx.utools.club/zhidi/info/list";
        String data = "{\n" +
                "    \n" +
                "    \"id\": 44\n" +
                "    \n" +
                "}";
        JSONObject jsonObject = JSON.parseObject(data);
        for (int i = 0; i < 10; i++) {
            String post = restTemplateUtils.post(url, jsonObject, String.class);
            System.out.println("--->" + post);
        }
    }

    @Test
    public void test1() {
        String array = "2610\n" +
                "5477\n" +
                "6421\n" +
                "14457\n" +
                "11405\n" +
                "15684\n" +
                "5793\n";

        String[] split = array.split("\n");
        Integer result = 0;
        for (int i = 0; i < split.length; i++) {
            Integer count = Integer.valueOf(split[i]);
            if (i == 0) {
                result = count;
                System.out.println(count);
            } else {
                result = result + count;
                System.out.println(result);
            }
        }
    }


//    @Test
//    public void dowloadImg() {
//        String img = "https://image1.ljcdn.com/x-se/hdic-frame/prod-bfd3b9b7-a806-4a87-b698-ed917c06211a.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-7c46b149-ae30-4be1-a263-ab175243282a.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-e5cf3040-aa82-43b8-98df-7fbddaeb16c0.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-528bf7e3-5b89-4559-9ee4-11ae7ad369d0.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-23729179-edcd-480e-88bc-dad6e1d3c267.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-2734f121-8fa2-40d3-9d57-24f0af794e71.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-2a9f5018-99ef-4fbe-a8fc-3492637f1ad3.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-0765219d-0b74-4317-bdce-c2756c4b63c4.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-45790885-ce05-4e5d-8b61-8dfe01f3cbb4.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-f7b2dfb7-282c-4c60-9cee-1405f345ace5.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-0d947000-ca31-466c-be03-29d36a963b4e.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-f8a0138d-675b-4a94-b82d-85a5f1175be2.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-8900b029-fe84-4492-b3fe-400d4ff0c7f1.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-d1824b02-d9ef-455a-8c63-155295b2f85e.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-0aa34348-5497-4099-be46-26475a4cea7f.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-7dc749da-50c2-43f5-aaf2-dd2520e43dce.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-05502762-de5d-432c-b34e-48fc17626ee8.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-bd158eab-4be2-4b33-b217-3b2a7cbb127c.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-86019a37-2d06-40de-b9fc-58e7953d0566.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-92352810-1d78-40a2-8fb4-a58fcb085835.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-9858afd1-c966-4f8b-b8aa-d4d93e1d7c0a.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-2728c804-d1a7-4654-81f9-6b981a8753ac.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-5fc826b3-594d-484c-bf60-9233e39d325d.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-46f41f29-d4b4-4c8b-b664-1620c7fefcf3.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-1a1f66d2-07fc-4de0-b761-9402f189ef70.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-2a1c3845-6d9b-4391-9496-33d60b195f58.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-4676de1d-4a2e-484a-9082-0edd037245f6.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-c126c932-510e-4539-b69d-f1076ca6b13b.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-b513d7d5-dfe4-4f2b-a0c4-82054dd905dd.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-8e6ffcd5-fdea-4427-820c-9c491235f431.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-10e7d74b-32c5-4202-992b-f1ec8f02b5e1.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-72434446-c7e7-465e-a874-36fa40f4495d.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-bec6582d-8d09-43cc-8538-bd983b8acd9b.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-e85f3248-563d-4aef-b42d-6acff394f8c2.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-a4f2a118-31f3-4e5f-868d-e3c46c6311e1.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-5d2943da-5592-461c-943d-3e473aa5706c.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-deb84650-1cba-45f2-8b7f-2629fc2795f7.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-4a5cb513-e0a5-4ffd-849e-dcfb9e4f59be.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-4ab3e9db-9f81-47cc-bd6e-68b460faa598.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-4f969cfd-ffdb-45c0-8829-f6d1ef059b1a.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-66d394fd-a3f7-4213-9127-024ae004b15c.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-1fab560d-520d-4cda-8efe-1d7ae28fb25a.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-9e15c80e-0502-4d4e-8d4e-54e13c811109.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-9b9da5dc-91b1-4913-942e-eafc9a98e8a8.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-80ff9510-7504-45c4-b49c-92d359491753.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-b0488260-478f-4af1-9505-9c244a78dd71.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-0c1be4d7-7a8b-4142-ad40-638ce521c3be.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-21197991-e60b-426a-9143-2340711da68c.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-c5ad83c4-b5ae-4a90-b197-9c69033bac1d.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/40c271d2-68aa-4c67-bbec-a274a26a0c58.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/2372564f-55a4-4376-8574-a553210c42bb.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-6d0357fc-8117-46a4-900a-8995713469fb.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-ce03e966-040c-4378-aa57-72ade311ed82.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-d0211e1c-e463-4e0b-abd4-04bd2b0e9ee5.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-ab5b5dd5-316c-493d-a3f0-820e3e808ad8.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-fdc1497b-1773-4a9a-a516-02776b1dbd54.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-6a51da59-412b-477a-858d-2b6a8d26c98f.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-a1df6e86-7202-490a-926e-8d7f6bd7a373.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-541cde2e-b69a-40db-a943-963ff141a5c3.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-5cd81120-6ca3-4cc8-bfb9-27e24add0c39.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-9b730207-58a5-4d9b-b980-02b2dd7c362d.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-9b6438a3-dabd-409d-b319-461425c01202.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-f432592e-c5fa-4cac-9a36-69a43efe38ac.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-bcfe644a-3fb1-4ff3-965d-ac6e17edbcaf.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-7cb323f4-c705-47ab-9e2e-86b7160dbade.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-b867bbb2-3114-4ff6-81fa-a4ca139ee2a0.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-b1bf05f4-c6fb-4872-aa51-e1138b4b08a2.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-9b1bc445-ad59-41e8-b4db-1dffb569dec3.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-4ec2283a-10b9-4203-8640-69e70c1eadc5.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-8a21f7ee-47a4-49e0-a772-bd5da5af98b2.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-7fdfeed0-56fe-4e60-92ae-4d09eb3f62d3.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-2473e607-eb48-4dc0-95bc-d4d037adbf29.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-51884466-c928-437f-ac39-a59f839c21cd.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-b9ae80af-2153-4ea1-a1c0-0cca979becba.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-ddf5062c-b89b-40bd-8eb9-8557c8b053f4.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-8c622f2f-3a60-40f0-a0b8-6ed660fc4756.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-a1d71be0-4506-48c0-ae84-f2fde02cab9c.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-19f9b208-fe7e-4b16-bf07-f7b217a51f33.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-b11558ea-876a-4d4f-b38b-54c243c8488d.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-3664742e-8e03-46af-ac6c-05f62293fe4d.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-9ff3ba52-d0f3-4deb-a44b-2e436067b5a0.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-03dd39ac-ee90-44b4-87d9-5f0f1a838bc2.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-fe813a90-0ede-4a0e-862e-604f76159514.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-564be582-e937-4433-bc75-c30b83b65757.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-a48ae876-ee41-49fa-a7f5-9958670950e4.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-bbd0a34d-dad6-4b10-9f27-56f9051de58d.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-4c8019b1-050e-48a9-b634-67c36507d5ff.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-a173bc3d-153c-4fc1-8fa6-3691cb922561.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-412f8ce3-14a9-4ca5-8e09-7c6273234ffb.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-8a3afaf4-666d-48ab-b363-b50b311e7a51.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-9c049e71-55a7-44a2-b851-946b1ddb3d80.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-e8f502b4-491d-467d-8c8f-c4a79adf29ff.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-079db416-3faf-4afd-9ba0-45a1aefd01f2.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-c1f458cd-6a08-4734-893a-102493668b27.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-31a8e003-438e-4812-8428-728c22aa7f12.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-8f309c46-cdd9-4e12-8f60-c79c59baf439.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-8b8e4441-6f3f-46fb-86c9-16706181d3cf.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-af75ea5d-79ab-458a-b92c-8e1860201964.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-ba6eef44-8a80-446c-89b1-3ca40b9e67b7.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-09ad34fa-7846-4e38-abf4-a1279f768cca.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-80b123ad-9084-4b77-a0b2-7b7087ed644f.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-7d5616d8-b620-4259-b70f-1ce29bebd8ca.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-d7eb924f-e0a1-41f0-ba24-f514d97748de.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-8018165d-72dd-4e09-b23f-473bd80fdf44.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-097e1fa2-f1b4-4069-80b7-5c9e8688ad94.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-f5504361-bce9-4d97-b2c2-c1bb1219a018.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-0c382fed-0504-454d-baf9-82edcc7a2433.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-3cd41a38-b858-4c03-9d39-d4842e85fc3d.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-71cb6f5f-2367-42a6-bb3b-77b45313e898.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-c87f003f-8370-42dc-9136-f9e693ebf91f.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-0f66797c-6c5c-4b06-9d44-79c754635882.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-af95facc-f6fd-46df-b73a-4b21c2958e86.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-aeac92fe-5165-48a4-9bce-a0ddb3f94618.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-4af40aaa-f269-41a6-9578-e5c5df29dc57.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-5d00d77f-96d4-43a6-b703-a7298f48cfc5.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-7dc21724-7f87-44e5-ba96-3c45b35b4c16.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-afec3724-53df-469a-a141-34992d7352a7.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-47f6ba1f-eeef-4d7c-a06f-d7897c16216c.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-6baf0dfa-6d23-4e4f-b2bd-0da1d1fbba92.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-b4d1575e-6029-4634-849e-c66410acd3e0.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-c97e9edc-e34a-42b8-8484-8c0f8a42b847.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-9f18c891-c391-4bce-8dd6-9866e5c3ad6e.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-3db353ed-b67f-45df-abe1-b6be04d7011c.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-7eed6a2b-48b0-4ca9-8af6-f6705b0eeab9.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-04163ded-ec5d-4a5a-a388-7b47202ce6e5.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-6f374538-e0a3-46da-91d2-437b7418f70a.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-dfb29eb4-74e6-4469-bf34-7565bc9a545d.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-725b0e15-fe28-4379-b944-c9fb102d064a.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-cd44387f-05e1-4afe-9cee-597a9b9b5a01.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-23931003-0676-4142-abce-cd62ffb5c204.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-cdc791a0-735b-46e0-93f5-415cce8f966b.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-d4fc151f-e4a3-473c-bf5f-2af4bef358bf.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-e2fb2c74-6b53-4627-8d4a-ccdce4e72f3f.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-2cfe457b-1cd1-4e73-af4c-c96a3523c9cb.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-ac9277b6-f75b-4a62-af7f-7aabccce15f3.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-90a11eba-8941-40a4-a948-c5bb0a9e20ea.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-64bdcc45-7992-4a0f-85f4-1c04dec6b407.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-0d169c66-a2da-4549-ab65-b9a8f81cbbd1.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-57f5ec1b-59f4-4a99-b949-55feb7571a9f.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-e705b601-af0d-4c9a-b7ef-200738b3442d.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-c9485caa-a810-4027-80b7-57e1ceb18ec0.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-e1945451-f3ba-48b5-b141-745838b988dd.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-041c70fa-c5d8-414d-9641-1c4f256d0da3.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-f3d6b99f-6267-4b74-af57-2e2bb1a003bd.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-1916332f-0a9a-462b-8278-56aaf34ad205.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-54731682-614f-466a-a261-737629b86161.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-7f654047-452a-4f97-a6fb-e21e9e9089a5.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-ae18d405-b432-4b59-84bb-713bdcd8dac4.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-d4f3b8c6-147e-4139-8f0f-c5c067b8fbb2.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-7b097521-74e9-44a6-92fa-5563740e900e.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-3818f48d-7eab-401f-9211-068b6dd41d33.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-dadb23f2-d00a-450e-8d00-efd35f9255e2.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-1296314e-f737-47ad-b08a-65ad0e22e2df.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-7be26721-2831-4eb5-bff8-73994998f1d4.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-1f074b76-35e8-4af4-94f9-75e96b73877d.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-17eab53e-ddb3-4a13-be31-e623c049cfef.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-fe17e3af-7e01-455b-ae41-6b3ec892bbe2.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-e88f5e37-f6e9-4711-8537-3c0f6bb7c298.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-462fd242-5037-4662-abab-4d9269270b38.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-e17b589f-af1b-4d31-ba0f-e347bd4d7bb0.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-4c5d7058-1356-4927-b215-a3a503031f17.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-067d1e3a-780a-4931-a067-4a5ee73d8757.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-bfac3193-7db5-4082-9669-1db000869e72.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-03c96953-9832-4f34-ae60-39aeb1843ff5.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-51092b79-5325-41c2-b705-79e8a33b3529.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-035b007e-c593-4d5b-afa9-d0f8207dc091.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-e5d0913b-c7f5-47a3-b0b9-e87a68f87164.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-c531fc58-25ed-4138-a3c5-d1fb4cd097cc.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-74a13c5a-c847-4e3f-96a6-d5b40659d405.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-3a99c880-b257-4d72-8e48-5c0e3fd0525f.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-935095c0-287f-4aff-b3e5-66b83976b48a.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-2551e19d-2ddb-4666-bb31-22f65e83290e.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-bb1dcd8c-d302-474a-ad13-cbbd63b4e05c.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-0962439b-0a20-4348-ae53-e68748087b6a.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-36cea2eb-dc8d-4d92-b149-ec1dc3fd9679.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-9afe5989-3250-488d-8676-9ebcff443c46.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-74444f52-6ab2-4c2c-a85d-98c40199c557.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-bf69e8ef-ed52-4b1a-b7cf-39e1f15b56e3.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-6af3c7fa-cc01-490c-9d57-2c3c84e08727.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-e7f6e16a-db79-4388-b549-df4519cfaee2.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-ea497d79-d8a5-4371-8a43-a5f019d35f3c.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-609e14ef-f7ea-40b0-bad3-ab829278bc78.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-ded7bd32-fd9e-4a78-9d1b-b84a3f7f93e7.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-fd30187c-62bc-4681-a7b9-b0a1fbc99d11.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-f198155a-c965-4ab2-bb14-4a102fed513e.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-37c6be60-4e87-49eb-862d-6c3148044edf.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-aab09108-68e4-457b-b391-a9c5eec1d149.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-3f1a66eb-9a10-4084-9c6b-ed0a319b5af5.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-fac41bf4-ad07-4625-bdb8-f7378da0f596.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-b45d9502-fbc4-42a0-9a39-99ece5e437b4.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-113ffff8-26ad-472f-abc0-2228be58eb4f.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-fbeb390e-3141-4c70-ac9e-b8742c7ffcfe.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-f0fca30a-3149-4bb6-928a-cd1a09ce88ea.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-1f411848-fec2-49bb-a313-9b7a3f39079a.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-dd762523-065b-4203-a174-5a389263592b.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-bbca6612-b5f4-4450-9fa1-0232e3397255.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-87bfa835-251f-4741-9d9c-b8b7d7f1b0b6.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-08e9bf85-12af-47bf-9612-86d33f6e089f.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-50a5792c-0a17-4630-a6ec-c00e32b9e4f1.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-602ba5d4-e77f-4108-83d0-65c0e3989d06.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-5a57f65a-5445-4c90-8eee-8137e67c35bb.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-f997b43d-587c-488b-8786-393eb0a357ca.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-0abfdfd6-1c2f-4236-809c-4a7914b7065f.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-ae8768c4-04c9-4621-9658-7fb17870f903.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-7588b562-ad55-466f-862a-6e7a4cbfbb83.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-3db94da1-ed2a-4540-b754-6da3bc4988df.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-31138d7c-ef87-4a8d-a74c-a1c1f7cd641b.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-f8869aa6-98d3-4cc1-8025-8a815a410625.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-66446d7f-2602-43c1-a70f-4b736c7917a0.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-80b487f5-1989-444b-9c65-7864e247b936.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/test-629228d6-632e-4da1-bacc-c53ead904983.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-35ca1d36-60a9-4e2c-8ed6-bfdd69ad38ec.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-9a00b673-8bfb-4b59-a72e-5ce3e2979923.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-d6f05e95-fe8f-4a57-9494-9b0198a4d49f.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-a00071a2-cfa5-4c53-99aa-cc2f50caa069.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-686eaed2-917b-40fd-882c-3eea8d24d1df.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-76e3eabd-d0c2-401d-97cc-4c7235bfed03.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-845cb713-a83d-4fd9-93bb-832fd447d5ed.png.1920x1880.jpg\n" +
//                "https://image1.ljcdn.com/x-se/hdic-frame/prod-c1d5f8dc-1888-4f45-b9bd-bf9403e4abcd.png.1920x1880.jpg\n";
//
//
//        String[] split = img.split("\n");
//        for (int i = 0; i < split.length; i++) {
//            String url = split[i];
//            if (StringUtils.isNotEmpty(url)) {
//                downloadPicture(url, "E:\\temp\\img\\" + (i + 1) + ".jpg");
//            }
//        }
//    }

    //链接url下载图片
    private static void downloadPicture(String urlList, String path) {
        URL url = null;
        try {
            url = new URL(urlList);
            DataInputStream dataInputStream = new DataInputStream(url.openStream());

            FileOutputStream fileOutputStream = new FileOutputStream(new File(path));
            ByteArrayOutputStream output = new ByteArrayOutputStream();

            byte[] buffer = new byte[1024];
            int length;

            while ((length = dataInputStream.read(buffer)) > 0) {
                output.write(buffer, 0, length);
            }
            fileOutputStream.write(output.toByteArray());
            dataInputStream.close();
            fileOutputStream.close();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}